* Stream replay support
* RFC8040 Restconf replay support: start-time and stop-time query parameter support
* This only applies to "native" restconf stream support, Nchan mode has different replay functionality
* RFC5277 Netconf replay support using <startTime> and
* Replay support is only in-memory and not persistent. External time-series DB could be added.
This commit is contained in:
parent
77e56868d4
commit
af16760279
13 changed files with 355 additions and 65 deletions
|
|
@ -51,17 +51,27 @@ struct stream_subscription{
|
|||
struct stream_subscription *ss_next;
|
||||
char *ss_stream; /* Name of associated stream */
|
||||
char *ss_xpath; /* Filter selector as xpath */
|
||||
struct timeval ss_stoptime; /* Replay stoptime */
|
||||
stream_fn_t ss_fn; /* Callback when event occurs */
|
||||
void *ss_arg; /* Callback argument */
|
||||
};
|
||||
|
||||
/* Replay time-series */
|
||||
struct stream_replay{
|
||||
qelem_t r_q; /* queue header */
|
||||
struct timeval r_tv; /* time index */
|
||||
cxobj *r_xml; /* event in xml form */
|
||||
};
|
||||
|
||||
/* See RFC8040 9.3, stream list, no replay support for now
|
||||
*/
|
||||
struct event_stream{
|
||||
struct event_stream *es_next;
|
||||
char *es_name; /* name of notification event stream */
|
||||
char *es_description;
|
||||
char *es_description;
|
||||
struct stream_subscription *es_subscription;
|
||||
int es_replay_enabled; /* set if replay is enables */
|
||||
struct stream_replay *es_replay;
|
||||
};
|
||||
typedef struct event_stream event_stream_t;
|
||||
|
||||
|
|
@ -69,25 +79,26 @@ typedef struct event_stream event_stream_t;
|
|||
* Prototypes
|
||||
*/
|
||||
event_stream_t *stream_find(clicon_handle h, const char *name);
|
||||
int stream_register(clicon_handle h, const char *name, const char *description);
|
||||
int stream_register(clicon_handle h, const char *name, const char *description, int replay_enabled);
|
||||
int stream_delete_all(event_stream_t *es);
|
||||
int stream_get_xml(clicon_handle h, int access, cbuf *cb);
|
||||
int stream_cb_add(clicon_handle h, char *stream, char *xpath, stream_fn_t fn, void *arg);
|
||||
struct stream_subscription *stream_cb_add(clicon_handle h, char *stream,
|
||||
char *xpath, struct timeval *stop, stream_fn_t fn, void *arg);
|
||||
int stream_cb_delete(clicon_handle h, char *stream, stream_fn_t fn, void *arg);
|
||||
int stream_notify_xml(clicon_handle h, char *stream, cxobj *xevent);
|
||||
int stream_notify_xml(clicon_handle h, event_stream_t *es, cxobj *xevent);
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
int stream_notify(clicon_handle h, char *stream, const char *event, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
#else
|
||||
int stream_notify(clicon_handle h, char *stream, const char *event, ...);
|
||||
#endif
|
||||
|
||||
/* Experimental publish streams using SSE */
|
||||
|
||||
int stream_replay(clicon_handle h, char *stream, struct timeval *start, struct timeval *stop);
|
||||
int stream_replay_add(event_stream_t *es, struct timeval *tv, cxobj *xv);
|
||||
|
||||
/* Experimental publish streams using SSE. CLIXON_PUBLISH_STREAMS should be set */
|
||||
int stream_publish(clicon_handle h, char *stream);
|
||||
int stream_publish_init();
|
||||
int stream_publish_exit();
|
||||
|
||||
/* Backward compatible macro for <1.8 */
|
||||
#define backend_notify_xml(h, stream, level, x) stream_notify_xml(h, stream, x)
|
||||
#define backend_notify(h, stream, level, event) stream_notify(h, stream, event)
|
||||
|
||||
#endif /* _CLIXON_STREAM_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue