events

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package events - Pub-Sub in go with event caching

Index

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 Event

type Event interface{}

All implementors must be amino-encodable.

type EventCallback

type EventCallback func(event Event)

type EventFilter

type EventFilter func(Event) bool

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 Fireable

type Fireable interface {
	FireEvent(ev Event)
}

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.

Jump to

Keyboard shortcuts

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