Documentation ¶
Index ¶
- Constants
- Variables
- func New(cfg StorageConfig, fss ...afero.Fs) (*eventManager, error)
- func NewDummy() *dummyEventManager
- type Event
- type EventManager
- type EventPusher
- type EventSubscriber
- type EventType
- type EventlogPosition
- type File
- type StorageConfig
- type SubscribeOption
- type Subscription
- type WriteSyncCloser
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 ¶
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 EventSubscriber ¶
type EventSubscriber interface { Subscribe(ctx context.Context, subscriberId string, opts ...SubscribeOption) (*Subscription, error) Unsubscribe(ctx context.Context, subscriberId string) error }
type EventType ¶ added in v0.3.5
type EventType int32
const ( Unspecified EventType = EventType(proto.EventType_Unspecified) PeerAdd EventType = EventType(proto.EventType_PeerAdd) PeerRemove EventType = EventType(proto.EventType_PeerRemove) PeerUpdate EventType = EventType(proto.EventType_PeerUpdate) PeerTraffic EventType = EventType(proto.EventType_PeerTraffic) PeerFirstConnect EventType = EventType(proto.EventType_PeerFirstConnect) )
type EventlogPosition ¶ added in v0.3.5
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 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
Click to show internal directories.
Click to hide internal directories.