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) Subscribe ¶
func (q *EventQueue) Subscribe(opts ...changestream.SubscriptionOption) (changestream.Subscription, error)
Subscribe creates a new subscription to the event queue. Options can be provided to allow filter during the dispatching phase.
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.