tendermint: github.com/tendermint/tendermint/libs/events Index | Files

package events

import "github.com/tendermint/tendermint/libs/events"

Package events - Pub-Sub in go with event caching

Index

Package Files

event_cache.go events.go

type ErrListenerWasRemoved Uses

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

ErrListenerWasRemoved is returned by AddEvent if the listener was removed.

func (ErrListenerWasRemoved) Error Uses

func (e ErrListenerWasRemoved) Error() string

Error implements the error interface.

type EventCache Uses

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 Uses

func NewEventCache(evsw Fireable) *EventCache

Create a new EventCache with an EventSwitch as backend

func (*EventCache) FireEvent Uses

func (evc *EventCache) FireEvent(event string, data EventData)

Cache an event to be fired upon finality.

func (*EventCache) Flush Uses

func (evc *EventCache) Flush()

Fire events by running evsw.FireEvent on all cached events. Blocks. Clears cached events

type EventCallback Uses

type EventCallback func(data EventData)

type EventData Uses

type EventData interface{}

EventData is a generic event data can be typed and registered with tendermint/go-amino via concrete implementation of this interface.

type EventSwitch Uses

type EventSwitch interface {
    cmn.Service
    Fireable

    AddListenerForEvent(listenerID, event string, cb EventCallback) error
    RemoveListenerForEvent(event string, listenerID string)
    RemoveListener(listenerID string)
}

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.

Listeners are added by calling AddListenerForEvent function. They can be removed by calling either RemoveListenerForEvent or RemoveListener (for all events).

func NewEventSwitch Uses

func NewEventSwitch() EventSwitch

type Eventable Uses

type Eventable interface {
    SetEventSwitch(evsw EventSwitch)
}

Eventable is the interface reactors and other modules must export to become eventable.

type Fireable Uses

type Fireable interface {
    FireEvent(event string, data EventData)
}

Fireable is the interface that wraps the FireEvent method.

FireEvent fires an event with the given name and data.

Package events imports 3 packages (graph) and is imported by 2 packages. Updated 2019-02-10. Refresh now. Tools for package owners.