Notification Manager
BangDB Notification Manager provides ways to create necessary constructs to deal with streams in time-series manner. It allows users to create stream, ingest data, define processing logic so that continuous ingestion and analysis can go on in automated manner.
To get instance of notification manager
BangDB Notification Manager (BangDBEnv *env, int nthreads = 4);
This returns an instance of notification manager given reference to BangDBEnv and number of threads that should be given to the manager to manage the notifications. See BangDBEnv for more details on the db environment.
To create or register a notification
int registerNotification(const char *notif_meta);
It takes notification metadata as input. Example of notification metadata:
{
"notifid":12345,
"name":"notif1",
"msg":"users msg",
"pri":1,
"mailto":[],
"endpoints":[
"http://192.168.1.3:10101/account"
],
"schemaid":1234,
"freq":1
}
It returns -1 for error else 0.
To drop or deregister a notification
void deregisterNotification(long notifid, short state);
state = 0 means pause, 1 means activate, -1 means delete completely.notifid
is the unique id which the user has provided while registering the notification. This API puts the notification in the queue for processing.
int put(long notifid, long pkts, long orig_streamid, const char *notif);
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. It return 0 for success. To get a list for notification generated based on given condition and filter query. This is exactly similar to scanDoc on BangDBTable. Please see DataQuery for more details on effective and right way of scan.
ResultSet *scanDoc(
ResultSet *prev_rs,
FDT *pk_skey = NULL,
FDT *pk_ekey = NULL,
const char *idx_filter_json = NULL,
ScanFilter *sf = NULL
);
It returns ResultSet if successful else NULL.
To get a list of registered notifications, call this function. This takes filter query and can do recursive scans. See DataQuery for more details.
ResultSet *scanRegisteredNotif(
ResultSet *prev_rs,
FDT *pk_skey = NULL,
FDT *pk_ekey = NULL,
const char *idx_filter_json = NULL,
ScanFilter *sf = NULL
);
It returns NULL for error.
To close Notification Manager
void close Notification Manager (CloseType ctype = DEFAULT_AT_CLIENT);