github.com/supragya/TendermintConnector@v0.0.0-20210619045051-113e32b84fb1/chains/tm34/libs/events/README.md (about) 1 2 3 # events 4 5 `import "github.com/supragya/TendermintConnector/chains/tm34/libs/events"` 6 7 * [Overview](#pkg-overview) 8 * [Index](#pkg-index) 9 10 ## Overview 11 12 Pub-Sub in go with event caching 13 14 ## Index 15 16 * [type EventCache](#EventCache) 17 * [func NewEventCache(evsw Fireable) *EventCache](#NewEventCache) 18 * [func (evc *EventCache) FireEvent(event string, data EventData)](#EventCache.FireEvent) 19 * [func (evc *EventCache) Flush()](#EventCache.Flush) 20 * [type EventCallback](#EventCallback) 21 * [type EventData](#EventData) 22 * [type EventSwitch](#EventSwitch) 23 * [func NewEventSwitch() EventSwitch](#NewEventSwitch) 24 * [type Eventable](#Eventable) 25 * [type Fireable](#Fireable) 26 27 28 ### Package files 29 30 [event_cache.go](/src/github.com/supragya/TendermintConnector/chains/tm34/libs/events/event_cache.go) [events.go](/src/github.com/supragya/TendermintConnector/chains/tm34/libs/events/events.go) 31 32 33 34 35 36 37 ## Type [EventCache](/src/target/event_cache.go?s=116:179#L5) 38 39 ``` go 40 type EventCache struct { 41 // contains filtered or unexported fields 42 } 43 ``` 44 45 An EventCache buffers events for a Fireable 46 All events are cached. Filtering happens on Flush 47 48 49 50 51 52 53 54 ### func [NewEventCache](/src/target/event_cache.go?s=239:284#L11) 55 56 ``` go 57 func NewEventCache(evsw Fireable) *EventCache 58 ``` 59 60 Create a new EventCache with an EventSwitch as backend 61 62 63 64 65 66 ### func (\*EventCache) [FireEvent](/src/target/event_cache.go?s=449:511#L24) 67 68 ``` go 69 func (evc *EventCache) FireEvent(event string, data EventData) 70 ``` 71 72 Cache an event to be fired upon finality. 73 74 75 76 77 ### func (\*EventCache) [Flush](/src/target/event_cache.go?s=735:765#L31) 78 79 ``` go 80 func (evc *EventCache) Flush() 81 ``` 82 83 Fire events by running evsw.FireEvent on all cached events. Blocks. 84 Clears cached events 85 86 87 88 89 ## Type [EventCallback](/src/target/events.go?s=4201:4240#L185) 90 91 ``` go 92 type EventCallback func(data EventData) 93 ``` 94 95 96 97 98 99 100 101 102 103 ## Type [EventData](/src/target/events.go?s=243:294#L14) 104 105 ``` go 106 type EventData interface { 107 } 108 ``` 109 110 Generic event data can be typed and registered with tendermint/go-amino 111 via concrete implementation of this interface 112 113 114 115 116 117 118 119 120 121 122 ## Type [EventSwitch](/src/target/events.go?s=560:771#L29) 123 124 ``` go 125 type EventSwitch interface { 126 service.Service 127 Fireable 128 129 AddListenerForEvent(listenerID, event string, cb EventCallback) 130 RemoveListenerForEvent(event string, listenerID string) 131 RemoveListener(listenerID string) 132 } 133 ``` 134 135 136 137 138 139 140 ### func [NewEventSwitch](/src/target/events.go?s=917:950#L46) 141 142 ``` go 143 func NewEventSwitch() EventSwitch 144 ``` 145 146 147 148 149 ## Type [Eventable](/src/target/events.go?s=378:440#L20) 150 151 ``` go 152 type Eventable interface { 153 SetEventSwitch(evsw EventSwitch) 154 } 155 ``` 156 157 reactors and other modules should export 158 this interface to become eventable 159 160 161 162 163 164 165 166 167 168 169 ## Type [Fireable](/src/target/events.go?s=490:558#L25) 170 171 ``` go 172 type Fireable interface { 173 FireEvent(event string, data EventData) 174 } 175 ``` 176 177 an event switch or cache implements fireable 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 - - - 193 Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)