bg
bangdb_notification_manager – Embedded C++ – BangDB = NoSQL + AI + Stream

bangdb_notification_manager – Embedded C++

chevron

bangdb_notification_manager

Embedded, C++

static bangdb_notification_manager* get_notification_manager_instance(bangdb_database *bdb, int nthreads);
This returns instance of notification manager given reference to bangdb_database and number of threads that should be given to the manager to manage the notifications. It returns the notification manager reference or NULL for error
int register_notification(const char *notif_meta);
To register a notification, this api is useful. It takes json metadata for the notification to be registered. The notification metadata looks like following

{"notifid":12345,"name":"notif1","msg":"users msg","rule":"notification rule/condition","pri":1,"mailto":[],"endpoints":["http://192.168.1.3:10101/account"],"schemaid":1234,"notif_streamid":4321,"notif_stream_name":"sdf","freq":1,"tags":["a"],"rel_streams":["s1"]}

The api returns 0 for success else -1 for error
// state = 0 means pause, 1 means activate, -1 means delete completely void deregister_notification(long notifid, short state);
Given a notification id, and state, this api will de-register the notification. State = 0 means pause the notification, state =1 means activate if it’s paused and state = - means delete the notification completely
int put(long notifid, long pkts, long orig_streamid, const char *notif);
This api puts the notification in the queue for processing.
pkts is the pk (timestamp) of the data which is in stream. This checks if notification is needed or not and if needed, then it queues the notifid for further work. Queued item must be sent to the respective destination.
If it doesn't need to send the notification then it calls send_notification with op = 0 to update the cnt, lts etc. and returns - it doesn't queue
This api returns 0 for success else -1 for error
int close_notification_manager(bool force = false);
This api formally closes the notification manager. Since the manager keeps reference counting, hence in case of force = false and open reference count more than 0, the manager will not be closed. Else it will be closed. It returns 0 for success else -1 for error