OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / tendermint / tmlibs / events / README.md
1
2
3 # events
4 `import "github.com/tendermint/tmlibs/events"`
5
6 * [Overview](#pkg-overview)
7 * [Index](#pkg-index)
8
9 ## <a name="pkg-overview">Overview</a>
10 Pub-Sub in go with event caching
11
12
13
14
15 ## <a name="pkg-index">Index</a>
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 #### <a name="pkg-files">Package files</a>
29 [event_cache.go](/src/github.com/tendermint/tmlibs/events/event_cache.go) [events.go](/src/github.com/tendermint/tmlibs/events/events.go) [log.go](/src/github.com/tendermint/tmlibs/events/log.go) 
30
31
32
33
34
35
36 ## <a name="EventCache">type</a> [EventCache](/src/target/event_cache.go?s=152:215#L1)
37 ``` go
38 type EventCache struct {
39     // contains filtered or unexported fields
40 }
41 ```
42 An EventCache buffers events for a Fireable
43 All events are cached. Filtering happens on Flush
44
45
46
47
48
49
50
51 ### <a name="NewEventCache">func</a> [NewEventCache](/src/target/event_cache.go?s=275:320#L5)
52 ``` go
53 func NewEventCache(evsw Fireable) *EventCache
54 ```
55 Create a new EventCache with an EventSwitch as backend
56
57
58
59
60
61 ### <a name="EventCache.FireEvent">func</a> (\*EventCache) [FireEvent](/src/target/event_cache.go?s=534:596#L19)
62 ``` go
63 func (evc *EventCache) FireEvent(event string, data EventData)
64 ```
65 Cache an event to be fired upon finality.
66
67
68
69
70 ### <a name="EventCache.Flush">func</a> (\*EventCache) [Flush](/src/target/event_cache.go?s=773:803#L26)
71 ``` go
72 func (evc *EventCache) Flush()
73 ```
74 Fire events by running evsw.FireEvent on all cached events. Blocks.
75 Clears cached events
76
77
78
79
80 ## <a name="EventCallback">type</a> [EventCallback](/src/target/events.go?s=4182:4221#L175)
81 ``` go
82 type EventCallback func(data EventData)
83 ```
84
85
86
87
88
89
90
91
92
93 ## <a name="EventData">type</a> [EventData](/src/target/events.go?s=236:287#L4)
94 ``` go
95 type EventData interface {
96 }
97 ```
98 Generic event data can be typed and registered with tendermint/go-wire
99 via concrete implementation of this interface
100
101
102
103
104
105
106
107
108
109
110 ## <a name="EventSwitch">type</a> [EventSwitch](/src/target/events.go?s=553:760#L19)
111 ``` go
112 type EventSwitch interface {
113     Service
114     Fireable
115
116     AddListenerForEvent(listenerID, event string, cb EventCallback)
117     RemoveListenerForEvent(event string, listenerID string)
118     RemoveListener(listenerID string)
119 }
120 ```
121
122
123
124
125
126
127 ### <a name="NewEventSwitch">func</a> [NewEventSwitch](/src/target/events.go?s=902:935#L36)
128 ``` go
129 func NewEventSwitch() EventSwitch
130 ```
131
132
133
134
135 ## <a name="Eventable">type</a> [Eventable](/src/target/events.go?s=371:433#L10)
136 ``` go
137 type Eventable interface {
138     SetEventSwitch(evsw EventSwitch)
139 }
140 ```
141 reactors and other modules should export
142 this interface to become eventable
143
144
145
146
147
148
149
150
151
152
153 ## <a name="Fireable">type</a> [Fireable](/src/target/events.go?s=483:551#L15)
154 ``` go
155 type Fireable interface {
156     FireEvent(event string, data EventData)
157 }
158 ```
159 an event switch or cache implements fireable
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174 - - -
175 Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)