sysrepo
3.3.4
YANG-based system repository for all-around configuration management.
|
Functions | |
int | sr_get_event_pipe (sr_subscription_ctx_t *subscription, int *event_pipe) |
Get the event pipe of a subscription. Do not call unless SR_SUBSCR_NO_THREAD flag was used when subscribing! Event pipe can be used in select() , poll() , or similar functions to listen for new events. It will then be ready for reading. More... | |
uint32_t | sr_subscription_get_last_sub_id (const sr_subscription_ctx_t *subscription) |
Get the subscription ID of the last created subscription. More... | |
int | sr_subscription_get_suspended (sr_subscription_ctx_t *subscription, uint32_t sub_id, int *suspended) |
Learn the suspend state of a specific subscription. More... | |
int | sr_subscription_process_events (sr_subscription_ctx_t *subscription, sr_session_ctx_t *session, struct timespec *wake_up_in) |
Process any pending new events on a subscription. Should not be called unless SR_SUBSCR_NO_THREAD flag was used when subscribing! Usually called after this subscription's event pipe is ready for reading but can also be called periodically. More... | |
int | sr_subscription_resume (sr_subscription_ctx_t *subscription, uint32_t sub_id) |
Resume a previously suspended subscription. Special SR_EV_NOTIF_RESUMED notification is delivered for resumed notification subscriptions. More... | |
int | sr_subscription_suspend (sr_subscription_ctx_t *subscription, uint32_t sub_id) |
Suspend a specific subscription. Special SR_EV_NOTIF_SUSPENDED notification is delivered for suspended notification subscriptions. More... | |
int | sr_subscription_thread_resume (sr_subscription_ctx_t *subscription) |
Resume the default handler thread of a subscription structure that was suspended previously. More... | |
int | sr_subscription_thread_suspend (sr_subscription_ctx_t *subscription) |
Suspend the default handler thread of a subscription structure. Meaning it will stop handling any events on the subscription until it is resumed. More... | |
int | sr_unsubscribe (sr_subscription_ctx_t *subscription) |
Unsubscribe all the subscriptions in a subscription structure and free it. More... | |
int | sr_unsubscribe_sub (sr_subscription_ctx_t *subscription, uint32_t sub_id) |
Unsubscribe a specific or all the subscriptions in a subscription structure. More... | |
enum | sr_subscr_flag_t { SR_SUBSCR_DEFAULT = 0x00, SR_SUBSCR_NO_THREAD = 0x01, SR_SUBSCR_PASSIVE = 0x02, SR_SUBSCR_DONE_ONLY = 0x04, SR_SUBSCR_ENABLED = 0x08, SR_SUBSCR_UPDATE = 0x10, SR_SUBSCR_OPER_MERGE = 0x20, SR_SUBSCR_THREAD_SUSPEND = 0x40, SR_SUBSCR_OPER_POLL_DIFF = 0x80, SR_SUBSCR_FILTER_ORIG = 0x0100, SR_SUBSCR_CHANGE_ALL_MODULES = 0x0200 } |
Flags used to override default handling of subscriptions. More... | |
typedef struct sr_subscription_ctx_s | sr_subscription_ctx_t |
Sysrepo subscription context returned from sr_*_subscribe calls, it is supposed to be released by the caller using sr_unsubscribe call. More... | |
typedef uint32_t | sr_subscr_options_t |
Options overriding default behavior of subscriptions, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags. More... | |
typedef uint32_t sr_subscr_options_t |
Options overriding default behavior of subscriptions, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags.
Definition at line 478 of file sysrepo_types.h.
typedef struct sr_subscription_ctx_s sr_subscription_ctx_t |
Sysrepo subscription context returned from sr_*_subscribe calls, it is supposed to be released by the caller using sr_unsubscribe call.
Definition at line 472 of file sysrepo_types.h.
enum sr_subscr_flag_t |
Flags used to override default handling of subscriptions.
Enumerator | |
---|---|
SR_SUBSCR_DEFAULT |
Default behavior of the subscription. In case of sr_module_change_subscribe call it means that:
|
SR_SUBSCR_NO_THREAD |
There will be no thread created for handling this subscription meaning no event will be processed! Use this flag when the application has its own event loop and it will listen for and process events manually (see sr_get_event_pipe and sr_subscription_process_events). |
SR_SUBSCR_PASSIVE |
The subscriber is not the "owner" of the subscribed data tree, just a passive watcher for changes. When this option is passed in to sr_module_change_subscribe, the subscription will have no effect on the presence of the subtree in the operational datastore. |
SR_SUBSCR_DONE_ONLY |
The subscriber does not support verification of the changes and wants to be notified only after the changes has been applied in the datastore, without the possibility to deny them (it will not receive SR_EV_CHANGE nor SR_EV_ABORT but only SR_EV_DONE events). |
SR_SUBSCR_ENABLED |
The subscriber wants to be notified about the current configuration at the moment of subscribing. It will receive SR_EV_ENABLED event, whose applying can fail causing the whole subscription to fail. On success this event will be followed by SR_EV_DONE. Be careful, SR_EV_ENABLED will be triggered even if there are no data so there will not be any changes! Also, this event callback is called as part of the subscribe call (in the same thread) unlike other events. |
SR_SUBSCR_UPDATE |
The subscriber will be called before any other subscribers for the particular module with an additional SR_EV_UPDATE event and is then allowed to modify the new module data. It can add new changes by calling standard set functions (such as sr_set_item_str) on the implicit callback session and returning. Note that you cannot subscribe more callbacks with this flag on one module with the same priority. |
SR_SUBSCR_OPER_MERGE |
Instead of removing any previous existing matching data before getting them from an operational subscription callback, keep them. Then the returned data are merged into the existing data. Accepted only for sr_oper_get_subscribe(). |
SR_SUBSCR_THREAD_SUSPEND |
Suspend the default handler thread before adding the subscription if it is running. In case of the first subscription, start the handler thread suspended. Meaning any events will not be handled until sr_subscription_thread_resume() is called. |
SR_SUBSCR_OPER_POLL_DIFF |
On every data retrieval additionally compute diff with the previous data and report the changes to any operational data module change subscriptions. Accepted only for sr_oper_poll_subscribe(). |
SR_SUBSCR_FILTER_ORIG |
Normally, XPath filter is applied by the listener (subscriber) for counting its statistics of filtered-out events. Using this option the event originator performs the filtering to unburden the subscriber of unnecessary event handling but results in 0 filtered-out changes returned by sr_module_change_sub_get_info(). Accepted only for sr_module_change_subscribe(). |
SR_SUBSCR_CHANGE_ALL_MODULES |
If you call getters (sr_get_data()) in the module change callback for data from other modules than the one the callback subscribed for, use this flag. Normally, only the changes of the subscribed module are sent to the callback so it retrieves the old data of other modules. |
Definition at line 378 of file sysrepo_types.h.
int sr_get_event_pipe | ( | sr_subscription_ctx_t * | subscription, |
int * | event_pipe | ||
) |
Get the event pipe of a subscription. Do not call unless SR_SUBSCR_NO_THREAD flag was used when subscribing! Event pipe can be used in select()
, poll()
, or similar functions to listen for new events. It will then be ready for reading.
[in] | subscription | Subscription without a listening thread. |
[out] | event_pipe | Event pipe of the subscription, do not close! It will be closed when the subscription is unsubscribed. |
uint32_t sr_subscription_get_last_sub_id | ( | const sr_subscription_ctx_t * | subscription | ) |
Get the subscription ID of the last created subscription.
[in] | subscription | Subscription context to read from. |
int sr_subscription_get_suspended | ( | sr_subscription_ctx_t * | subscription, |
uint32_t | sub_id, | ||
int * | suspended | ||
) |
Learn the suspend state of a specific subscription.
[in] | subscription | Subscription context to use. |
[in] | sub_id | Subscription ID of the subscription to check. |
[out] | suspended | Whether the subscription is suspended or not. |
int sr_subscription_process_events | ( | sr_subscription_ctx_t * | subscription, |
sr_session_ctx_t * | session, | ||
struct timespec * | wake_up_in | ||
) |
Process any pending new events on a subscription. Should not be called unless SR_SUBSCR_NO_THREAD flag was used when subscribing! Usually called after this subscription's event pipe is ready for reading but can also be called periodically.
[in] | subscription | Subscription without a listening thread with some new events. |
[in] | session | Optional session for storing errors. |
[out] | wake_up_in | Optional time when a scheduled event occurs and this function should be called again. It can be the nearest notification subscription stop time or operational poll subscription cache update. If there are no scheduled events in future, it is zeroed. |
int sr_subscription_resume | ( | sr_subscription_ctx_t * | subscription, |
uint32_t | sub_id | ||
) |
Resume a previously suspended subscription. Special SR_EV_NOTIF_RESUMED notification is delivered for resumed notification subscriptions.
[in] | subscription | Subscription context to use. |
[in] | sub_id | Subscription ID of the specific subscription to resume. |
int sr_subscription_suspend | ( | sr_subscription_ctx_t * | subscription, |
uint32_t | sub_id | ||
) |
Suspend a specific subscription. Special SR_EV_NOTIF_SUSPENDED notification is delivered for suspended notification subscriptions.
[in] | subscription | Subscription context to use. |
[in] | sub_id | Subscription ID of the specific subscription to suspend. |
int sr_subscription_thread_resume | ( | sr_subscription_ctx_t * | subscription | ) |
Resume the default handler thread of a subscription structure that was suspended previously.
[in] | subscription | Subscription context with a handler thread. |
int sr_subscription_thread_suspend | ( | sr_subscription_ctx_t * | subscription | ) |
Suspend the default handler thread of a subscription structure. Meaning it will stop handling any events on the subscription until it is resumed.
[in] | subscription | Subscription context with a handler thread. |
int sr_unsubscribe | ( | sr_subscription_ctx_t * | subscription | ) |
Unsubscribe all the subscriptions in a subscription structure and free it.
[in] | subscription | Subscription context to free. |
int sr_unsubscribe_sub | ( | sr_subscription_ctx_t * | subscription, |
uint32_t | sub_id | ||
) |
Unsubscribe a specific or all the subscriptions in a subscription structure.
If all subscriptions are being unsubscribed, the subscription structure can still be used normally until sr_unsubscribe() is called, even if there are no actual subscriptions left in it. This is useful for preventing dead locks if using the subscription in a custom event loop.
[in] | subscription | Subscription context to use. |
[in] | sub_id | Subscription ID of the subscription to unsubscribe, 0 for all the subscriptions. |