Files
tendermint/libs/events
Sam Kleinman 7a0b05f22d libs/events: remove unneccessary unsubscription code (#8135)
The events switch code is largely vestigal and is responsible for
wiring between the consensus state machine and the consensus
reactor. While there might have been a need, historicallly to managed
these subscriptions at runtime, it's nolonger used: subscriptions are
registered during startup, and then the switch shuts down at at the
end. 

Eventually the EventSwitch should be replaced by a much smaller
implementation of an eventloop in the consensus state machine, but
cutting down on the scope of the event switch will help clarify the
requirements from the consensus side.
2022-03-17 13:02:02 +00:00
..
2020-08-17 16:40:50 +02:00

events

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

Overview

Pub-Sub in go with event caching

Index

Package files

event_cache.go events.go

Type EventCache

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

func NewEventCache(evsw Fireable) *EventCache

Create a new EventCache with an EventSwitch as backend

func (*EventCache) FireEvent

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

Cache an event to be fired upon finality.

func (*EventCache) Flush

func (evc *EventCache) Flush()

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

Type EventCallback

type EventCallback func(data EventData)

Type EventData

type EventData interface {
}

Generic event data can be typed and registered with tendermint/go-amino via concrete implementation of this interface

Type EventSwitch

type EventSwitch interface {
    service.Service
    Fireable

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

func NewEventSwitch

func NewEventSwitch() EventSwitch

Type Eventable

type Eventable interface {
    SetEventSwitch(evsw EventSwitch)
}

reactors and other modules should export this interface to become eventable

Type Fireable

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

an event switch or cache implements fireable


Generated by godoc2md