tendermint/libs/events
Dev Ojha dae7dc30e0 Switch usage of math/rand to cmn's rand (#1980)
This commit switches all usage of math/rand to cmn's rand. The only
exceptions are within the random file itself, the tools package, and the
crypto package. In tools you don't want it to lock between the go-routines.
The crypto package doesn't use it so the crypto package have no other
dependencies within tendermint/tendermint for easier portability.

Crypto/rand usage is unadjusted.

Closes #1343
2018-07-16 11:20:37 +04:00
..
Makefile copy events and pubsub packages from tmlibs 2018-05-21 10:51:47 +04:00
README.md copy events and pubsub packages from tmlibs 2018-05-21 10:51:47 +04:00
event_cache.go copy events and pubsub packages from tmlibs 2018-05-21 10:51:47 +04:00
event_cache_test.go copy events and pubsub packages from tmlibs 2018-05-21 10:51:47 +04:00
events.go fix import paths 2018-07-01 22:36:49 -04:00
events_test.go Switch usage of math/rand to cmn's rand (#1980) 2018-07-16 11:20:37 +04:00

README.md

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 {
    cmn.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