eventqueue

package
v0.0.0-...-51a0f74 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventQueue

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

EventQueue defines an event listener and dispatcher for db changes that can be multiplexed to subscriptions. The event queue allows consumers to subscribe via callbacks to the event queue. This is a lockless implementation, all subscriptions and changes are serialized in the main loop. Dispatching is randomized to ensure that subscriptions don't depend on ordering. The subscriptions can be associated with different subscription options, which provide filtering when dispatching. Unsubscribing is provided per subscription, which is done asynchronously.

func New

func New(stream Stream, logger Logger) (*EventQueue, error)

New creates a new EventQueue that will use the Stream for events.

func (*EventQueue) Kill

func (q *EventQueue) Kill()

Kill stops the event queue.

func (*EventQueue) Subscribe

Subscribe creates a new subscription to the event queue. Options can be provided to allow filter during the dispatching phase.

func (*EventQueue) Wait

func (q *EventQueue) Wait() error

Wait waits for the event queue to stop.

type Logger

type Logger interface {
	Infof(message string, args ...interface{})
	Tracef(message string, args ...interface{})
	IsTraceEnabled() bool
}

Logger represents the logging methods called.

type Stream

type Stream interface {
	// Changes returns a channel for a given namespace (database).
	Changes() <-chan changestream.ChangeEvent
}

Stream represents a way to get change events.

Jump to

Keyboard shortcuts

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