You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
2.9 KiB

  1. # events
  2. `import "github.com/tendermint/tendermint/libs/events"`
  3. * [Overview](#pkg-overview)
  4. * [Index](#pkg-index)
  5. ## Overview
  6. Pub-Sub in go with event caching
  7. ## Index
  8. * [type EventCache](#EventCache)
  9. * [func NewEventCache(evsw Fireable) *EventCache](#NewEventCache)
  10. * [func (evc *EventCache) FireEvent(event string, data EventData)](#EventCache.FireEvent)
  11. * [func (evc *EventCache) Flush()](#EventCache.Flush)
  12. * [type EventCallback](#EventCallback)
  13. * [type EventData](#EventData)
  14. * [type EventSwitch](#EventSwitch)
  15. * [func NewEventSwitch() EventSwitch](#NewEventSwitch)
  16. * [type Eventable](#Eventable)
  17. * [type Fireable](#Fireable)
  18. ### Package files
  19. [event_cache.go](/src/github.com/tendermint/tendermint/libs/events/event_cache.go) [events.go](/src/github.com/tendermint/tendermint/libs/events/events.go)
  20. ## Type [EventCache](/src/target/event_cache.go?s=116:179#L5)
  21. ``` go
  22. type EventCache struct {
  23. // contains filtered or unexported fields
  24. }
  25. ```
  26. An EventCache buffers events for a Fireable
  27. All events are cached. Filtering happens on Flush
  28. ### func [NewEventCache](/src/target/event_cache.go?s=239:284#L11)
  29. ``` go
  30. func NewEventCache(evsw Fireable) *EventCache
  31. ```
  32. Create a new EventCache with an EventSwitch as backend
  33. ### func (\*EventCache) [FireEvent](/src/target/event_cache.go?s=449:511#L24)
  34. ``` go
  35. func (evc *EventCache) FireEvent(event string, data EventData)
  36. ```
  37. Cache an event to be fired upon finality.
  38. ### func (\*EventCache) [Flush](/src/target/event_cache.go?s=735:765#L31)
  39. ``` go
  40. func (evc *EventCache) Flush()
  41. ```
  42. Fire events by running evsw.FireEvent on all cached events. Blocks.
  43. Clears cached events
  44. ## Type [EventCallback](/src/target/events.go?s=4201:4240#L185)
  45. ``` go
  46. type EventCallback func(data EventData)
  47. ```
  48. ## Type [EventData](/src/target/events.go?s=243:294#L14)
  49. ``` go
  50. type EventData interface {
  51. }
  52. ```
  53. Generic event data can be typed and registered with tendermint/go-amino
  54. via concrete implementation of this interface
  55. ## Type [EventSwitch](/src/target/events.go?s=560:771#L29)
  56. ``` go
  57. type EventSwitch interface {
  58. service.Service
  59. Fireable
  60. AddListenerForEvent(listenerID, event string, cb EventCallback)
  61. RemoveListenerForEvent(event string, listenerID string)
  62. RemoveListener(listenerID string)
  63. }
  64. ```
  65. ### func [NewEventSwitch](/src/target/events.go?s=917:950#L46)
  66. ``` go
  67. func NewEventSwitch() EventSwitch
  68. ```
  69. ## Type [Eventable](/src/target/events.go?s=378:440#L20)
  70. ``` go
  71. type Eventable interface {
  72. SetEventSwitch(evsw EventSwitch)
  73. }
  74. ```
  75. reactors and other modules should export
  76. this interface to become eventable
  77. ## Type [Fireable](/src/target/events.go?s=490:558#L25)
  78. ``` go
  79. type Fireable interface {
  80. FireEvent(event string, data EventData)
  81. }
  82. ```
  83. an event switch or cache implements fireable
  84. - - -
  85. Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)