* 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
|
|
@ -165,6 +165,11 @@ int clicon_quiet_mode_set(clicon_handle h, int val);
|
|||
yang_spec * clicon_dbspec_yang(clicon_handle h);
|
||||
int clicon_dbspec_yang_set(clicon_handle h, struct yang_spec *ys);
|
||||
|
||||
#if 1 /* Temporary function until "Top-level Yang symbol cannot be called "config"" is fixed */
|
||||
yang_spec * clicon_config_yang(clicon_handle h);
|
||||
int clicon_config_yang_set(clicon_handle h, struct yang_spec *ys);
|
||||
#endif
|
||||
|
||||
cxobj *clicon_conf_xml(clicon_handle h);
|
||||
int clicon_conf_xml_set(clicon_handle h, cxobj *x);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,17 +37,30 @@
|
|||
#ifndef _CLIXON_QUEUE_H_
|
||||
#define _CLIXON_QUEUE_H_
|
||||
|
||||
/*
|
||||
* Circular queue structure for use as first entry in a parent structure.
|
||||
/*! Circular queue structure for use as first entry in a parent structure.
|
||||
* Add qelem_t as first element in struct
|
||||
* @code
|
||||
* struct a{
|
||||
* qelem_t a_q; # this must be there
|
||||
* int a_b; # other elements
|
||||
* ...
|
||||
* };
|
||||
* @endcode
|
||||
*/
|
||||
typedef struct _qelem_t {
|
||||
struct _qelem_t *q_next;
|
||||
struct _qelem_t *q_prev;
|
||||
} qelem_t;
|
||||
|
||||
/*
|
||||
* Append element 'elem' to queue.
|
||||
*/
|
||||
/*! Append element 'elem' to queue.
|
||||
* @param[in] elem Element to be added
|
||||
* @param[in,out] pred Add element after this
|
||||
* @code
|
||||
* struct a *list; # existing list
|
||||
* struct a *new = malloc(...);
|
||||
* ADDQ(new, list);
|
||||
* @endcode
|
||||
*/
|
||||
#define ADDQ(elem, pred) { \
|
||||
register qelem_t *Xe = (qelem_t *) (elem); \
|
||||
register qelem_t *Xp = (qelem_t *) (pred); \
|
||||
|
|
@ -62,8 +75,14 @@ typedef struct _qelem_t {
|
|||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert element 'elem' in queue after 'pred'
|
||||
/*! Insert element 'elem' in queue after 'pred'
|
||||
* @param[in] elem Element to be added
|
||||
* @param[in,out] pred Add element after this
|
||||
* @code
|
||||
* struct a *list; # existing list
|
||||
* struct a *new = malloc(...);
|
||||
* INSQ(new, list);
|
||||
* @endcode
|
||||
*/
|
||||
#define INSQ(elem, pred) { \
|
||||
register qelem_t *Xe = (qelem_t *) (elem); \
|
||||
|
|
@ -79,9 +98,16 @@ typedef struct _qelem_t {
|
|||
pred = elem; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove element 'elem' from queue. 'head' is the pointer to the queue and
|
||||
/*! Remove element 'elem' from queue. 'head' is the pointer to the queue and
|
||||
* is of 'type'.
|
||||
* @param[in] elem
|
||||
* @param[in] head
|
||||
* @param[in] type XXX needed?
|
||||
* @code
|
||||
* struct a *list; # existing list
|
||||
* struct a *el; # remove this
|
||||
* DELQ(el, list, struct a*);
|
||||
* @endcode
|
||||
*/
|
||||
#define DELQ(elem, head, type) { \
|
||||
register qelem_t *Xe = (qelem_t *) elem; \
|
||||
|
|
@ -92,10 +118,13 @@ typedef struct _qelem_t {
|
|||
head = (type)Xe->q_next; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Get next entry in list
|
||||
/*! Get next entry in list
|
||||
* @param[in] type Type of element
|
||||
* @param[in] el Return next element after elem.
|
||||
* @code
|
||||
* struct a *list; # existing element (or list)
|
||||
* NEXTQ(struct a*, el);
|
||||
*/
|
||||
#define NEXTQ(type, elem) ((type)((elem)?((qelem_t *)(elem))->q_next:NULL))
|
||||
|
||||
|
||||
#endif /* _CLIXON_QUEUE_H_ */
|
||||
|
|
|
|||
|
|
@ -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