6
6
*
7
7
* APIs are for publishing & receiving events with source, tag and params along with timestamp.
8
8
* Used by event publishers and those interested in receiving published events.
9
- * Publishers are multiple sources , as processes running in hosts & containers.
9
+ * Publishers are multiple run from different contexts , as processes running in hosts & containers.
10
10
* Receiver are often few. Telmetry container runs a receiver.
11
11
*
12
12
*/
13
13
14
14
15
+ /* Handle for a publisher / subscriber instance */
15
16
typedef void * event_handle_t ;
16
17
17
18
/*
@@ -20,8 +21,6 @@ typedef void* event_handle_t;
20
21
* A single publisher instance is maintained for a source.
21
22
* Any duplicate init call for a source will return the same instance.
22
23
*
23
- * Choosing cache will help read cached data, during downtime, if any.
24
- *
25
24
* NOTE:
26
25
* The initialization occurs asynchronously.
27
26
* Any event published before init is complete, is blocked until the init
@@ -47,7 +46,7 @@ event_handle_t events_init_publisher(const std::string event_source);
47
46
* Handle returned from events_init_publisher
48
47
*
49
48
* Output:
50
- * None
49
+ * Handle is nullified.
51
50
*/
52
51
void events_deinit_publisher (event_handle_t &handle);
53
52
@@ -101,8 +100,6 @@ int event_publish(event_handle_t handle, const std::string event_tag,
101
100
102
101
103
102
104
- typedef std::vector<std::string> event_subscribe_sources_t ;
105
-
106
103
/*
107
104
* Initialize subscriber.
108
105
* Init subscriber, optionally to filter by event-source.
@@ -112,6 +109,7 @@ typedef std::vector<std::string> event_subscribe_sources_t;
112
109
* When set to true, it will make use of the cache service transparently.
113
110
* The cache service caches events during session down time. The deinit
114
111
* start the caching and init call stops the caching.
112
+ * default: false
115
113
*
116
114
* recv_timeout
117
115
* Read blocks by default until an event is available for read.
@@ -124,11 +122,14 @@ typedef std::vector<std::string> event_subscribe_sources_t;
124
122
* List of subscription sources of interest.
125
123
* The source value is the corresponding YANG module name.
126
124
* e.g. "sonic-events-bgp " is the source modulr name for bgp.
125
+ * default: All sources, if none provided.
127
126
*
128
127
* Return:
129
128
* Non NULL handle on success
130
129
* NULL on failure
131
130
*/
131
+ typedef std::vector<std::string> event_subscribe_sources_t ;
132
+
132
133
event_handle_t events_init_subscriber (bool use_cache=false ,
133
134
int recv_timeout = -1 ,
134
135
const event_subscribe_sources_t *sources=NULL );
@@ -140,17 +141,18 @@ event_handle_t events_init_subscriber(bool use_cache=false,
140
141
* Handle returned from events_init_subscriber
141
142
*
142
143
* Output:
143
- * None
144
+ * Handle is nullified.
144
145
*/
145
146
void events_deinit_subscriber (event_handle_t &handle);
146
147
148
+
147
149
/*
148
150
* Receive an event.
149
- * A blocking call.
151
+ * A blocking call unless the subscriber is created with a timeout .
150
152
*
151
153
* This API maintains an expected sequence number and use the received
152
154
* sequence in event to compute missed events count. The missed count
153
- * set of events missed from this sender.
155
+ * provides the count of events missed from this sender.
154
156
*
155
157
* Received event:
156
158
* It is a form of JSON struct, with a single key and
@@ -198,18 +200,4 @@ int event_receive(event_handle_t handle, std::string &key,
198
200
*/
199
201
int event_last_error ();
200
202
201
-
202
- /*
203
- * Cache drain timeout.
204
- *
205
- * When de-init is called, it calls stop cache service.
206
- * But before this point, there could be events received in zmq's
207
- * local cache pending read and those that arrived since last read.
208
- * These events will not be seen by cache service.
209
- * So read those off and give it to cache service as starting stock.
210
- * As we don't have a clue on count in zmq's cache, read in non-block
211
- * mode for a period.
212
- */
213
- #define CACHE_DRAIN_IN_MILLISECS 1000
214
-
215
203
#endif /* !_EVENTS_H */
0 commit comments