Sam Kleinman bd6dc3ca88 | 3 years ago | |
---|---|---|
.. | ||
Makefile | 7 years ago | |
README.md | 4 years ago | |
event_cache.go | 3 years ago | |
event_cache_test.go | 3 years ago | |
events.go | 3 years ago | |
events_test.go | 3 years ago |
import "github.com/tendermint/tendermint/libs/events"
Pub-Sub in go with event caching
type EventCache struct {
// contains filtered or unexported fields
}
An EventCache buffers events for a Fireable All events are cached. Filtering happens on Flush
func NewEventCache(evsw Fireable) *EventCache
Create a new EventCache with an EventSwitch as backend
func (evc *EventCache) FireEvent(event string, data EventData)
Cache an event to be fired upon finality.
func (evc *EventCache) Flush()
Fire events by running evsw.FireEvent on all cached events. Blocks. Clears cached events
type EventCallback func(data EventData)
type EventData interface {
}
Generic event data can be typed and registered with tendermint/go-amino via concrete implementation of this interface
type EventSwitch interface {
service.Service
Fireable
AddListenerForEvent(listenerID, event string, cb EventCallback)
RemoveListenerForEvent(event string, listenerID string)
RemoveListener(listenerID string)
}
func NewEventSwitch() EventSwitch
type Eventable interface {
SetEventSwitch(evsw EventSwitch)
}
reactors and other modules should export this interface to become eventable
type Fireable interface {
FireEvent(event string, data EventData)
}
an event switch or cache implements fireable
Generated by godoc2md