Documentation
¶
Overview ¶
Package events - Pub-Sub in go with event caching
Index ¶
- func Subscribe(evsw EventSwitch, listenerID string) <-chan Event
- func SubscribeFiltered(evsw EventSwitch, listenerID string, filter EventFilter) <-chan Event
- func SubscribeFilteredOn(evsw EventSwitch, listenerID string, filter EventFilter, ch chan Event) <-chan Event
- func SubscribeOn(evsw EventSwitch, listenerID string, ch chan Event) <-chan Event
- func SubscribeToEvent(evsw EventSwitch, listenerID string, protoevent Event) <-chan Event
- func SubscribeToEventOn(evsw EventSwitch, listenerID string, protoevent Event, ch chan Event) <-chan Event
- type Event
- type EventCallback
- type EventFilter
- type EventSwitch
- type Eventable
- type FilterStream
- type Fireable
- type Listenable
- type StoreStream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Subscribe ¶
func Subscribe(evsw EventSwitch, listenerID string) <-chan Event
Returns a synchronous event emitter.
func SubscribeFiltered ¶
func SubscribeFiltered(evsw EventSwitch, listenerID string, filter EventFilter) <-chan Event
func SubscribeFilteredOn ¶
func SubscribeFilteredOn(evsw EventSwitch, listenerID string, filter EventFilter, ch chan Event) <-chan Event
func SubscribeOn ¶
func SubscribeOn(evsw EventSwitch, listenerID string, ch chan Event) <-chan Event
Like Subscribe, but lets the caller construct a channel. If the capacity of the provided channel is 0, it will be called synchronously; otherwise, it will drop when the capacity is reached and a select doesn't immediately send.
func SubscribeToEvent ¶
func SubscribeToEvent(evsw EventSwitch, listenerID string, protoevent Event) <-chan Event
func SubscribeToEventOn ¶
func SubscribeToEventOn(evsw EventSwitch, listenerID string, protoevent Event, ch chan Event) <-chan Event
Types ¶
type EventCallback ¶
type EventCallback func(event Event)
type EventFilter ¶
type EventSwitch ¶
type EventSwitch interface {
service.Service
Fireable
Listenable
}
EventSwitch is the interface for synchronous pubsub, where listeners subscribe to certain events and, when an event is fired (see Fireable), notified via a callback function. All listeners are expected to perform work quickly and not block processing of the main event emitter.
func NewEventSwitch ¶
func NewEventSwitch() EventSwitch
func NilEventSwitch ¶
func NilEventSwitch() EventSwitch
type Eventable ¶
type Eventable interface {
SetEventSwitch(evsw EventSwitch)
}
Eventable is the interface reactors and other modules must export to become eventable.
type FilterStream ¶
type FilterStream interface {
Eventable
}
FilterStream is listenable and lets you filter.
type Listenable ¶
type Listenable interface {
// Multiple callbacks can be registered for a given listenerID. Events are
// called back in the order that they were registered with this function.
AddListener(listenerID string, cb EventCallback)
// Removes all callbacks that match listenerID.
RemoveListener(listenerID string)
}
type StoreStream ¶
type StoreStream interface {
Eventable
SetHeight(height int64) // to demarcate height in WAL for replay.
}
StoreStream stores events to disk but is also listenaable.