eventlog

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MagicHI uint8 = 0xAA
	MagicLO uint8 = 0x55
)

Variables

View Source
var ErrAlreadySubscribed = errors.New("already subscribed")
View Source
var ErrNilEvent = errors.New("event is nil")
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrServiceStopped = errors.New("service stopped")
View Source
var ErrSubscriptionStopped = errors.New("subscription stopped")

Functions

func New

func New(cfg StorageConfig, fss ...afero.Fs) (*eventManager, error)

New initializes and starts the event log manager

func NewDummy

func NewDummy() *dummyEventManager

Types

type Event

type Event struct {
	Type      EventType `json:"type"`
	Timestamp int64     `json:"ts"`
	LogID     string    `json:"log_id"`
	Offset    int64     `json:"offset"`
	Data      []byte    `json:"data"`
}

func (Event) IntoProto

func (e Event) IntoProto() *proto.FetchEventsResponse

type EventManager

type EventManager interface {
	EventPusher
	EventSubscriber
	control.ServiceController
}

type EventPusher

type EventPusher interface {
	Push(eventType EventType, data interface{}) error
}

type EventSubscriber

type EventSubscriber interface {
	Subscribe(ctx context.Context, subscriberId string, opts ...SubscribeOption) (*Subscription, error)
	Unsubscribe(ctx context.Context, subscriberId string) error
}

type EventlogPosition added in v0.3.5

type EventlogPosition struct {
	LogID  string
	Offset int64
}

EventlogPosition describe where we want to start reading the log. Zero offset means the beginning of the file. Empty logID means the beginning of the whole journal.

type File

type File interface {
	io.Reader
	io.Writer
	io.Seeker
	io.Closer
	Stat() (os.FileInfo, error)
	Sync() error
}

type StorageConfig

type StorageConfig struct {
	// path to a log dir
	Dir string `json:"dir"`
	// number of files to maintain
	MaxFiles int `json:"max_files"`
	// for how long we want to write to a single logfile
	Period time.Duration `json:"period"`
	// how many bytes we want to write to a single logfile
	Size int64 `json:"size"`
}

type SubscribeOption added in v0.3.5

type SubscribeOption func(opts *subscribeOptions) error

func WithActiveLog added in v0.3.5

func WithActiveLog() SubscribeOption

Started from Active log disregarding the Position

func WithPosition added in v0.3.5

func WithPosition(position EventlogPosition) SubscribeOption

Used only if ActiveLog is not defined

func WithSkipEventAtPosition added in v0.3.5

func WithSkipEventAtPosition(skip bool) SubscribeOption

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

func (*Subscription) Close

func (s *Subscription) Close() <-chan struct{}

Close the subscriber. Might be called multiple times.

func (*Subscription) Events

func (s *Subscription) Events() <-chan Event

type WriteSyncCloser

type WriteSyncCloser interface {
	io.Writer
	io.Closer
	Sync() error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL