xref: /spdk/doc/notify.md (revision 1e1fd9ac219da3e52bc166c9d2bb2376c62c113d)
1# Notify library {#notify}
2
3The notify library implements an event bus, allowing users to register, generate,
4and listen for events. For example, the bdev library may register a new event type
5for bdev creation. Any time a bdev is created, it "sends" the event. Consumers of
6that event may periodically poll for new events to retrieve them.
7The event bus is implemented as a circular ring of fixed size. If event consumers
8do not poll frequently enough, events may be lost. All events are identified by a
9monotonically increasing integer, so missing events may be detected, although
10not recovered.
11
12## Register event types {#notify_register}
13
14During initialization the sender library should register its own event types using
15`spdk_notify_type_register(const char *type)`. Parameter 'type' is the name of
16notification type.
17
18## Get info about events {#notify_get_info}
19
20A consumer can get information about the available event types during runtime using
21`spdk_notify_foreach_type`, which iterates over registered notification types and
22calls a callback on each of them, so that user can produce detailed information
23about notification.
24
25## Get new events {#notify_listen}
26
27A consumer can get events by calling function `spdk_notify_foreach_event`.
28The caller should specify last received event and the maximum number of invocations.
29There might be multiple consumers of each event. The event bus is implemented as a
30circular buffer, so older events may be overwritten by newer ones.
31
32## Send events {#notify_send}
33
34When an event occurs, a library can invoke `spdk_notify_send` with two strings.
35One containing the type of the event, like "spdk_bdev_register", second with context,
36for example "Nvme0n1"
37
38## RPC Calls {#rpc_calls}
39
40See [JSON-RPC documentation](jsonrpc.md/#rpc_notify_get_types)
41