eventlog

package
v0.3.5-rc3-hotfix1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

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      uint32 `json:"type"`
	Timestamp int64  `json:"ts"`
	Data      []byte `json:"data"`
	LogID     string `json:"log_id"`
	Offset    int64  `json:"offset"`
}

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 uint32, timestamp int64, data interface{}) error
}

type EventSubscriber

type EventSubscriber interface {
	Subscribe(ctx context.Context, opts SubscriptionOpts) (*Subscription, error)
}

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 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) Errors

func (s *Subscription) Errors() <-chan error

func (*Subscription) Events

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

type SubscriptionOpts

type SubscriptionOpts struct {
	LogID  string
	Offset int64
	Labels map[string]string
}

SubscriptionOpts 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 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