numam-spdk/doc/notify.md
wuzhouhui ab3f35b226 lib/notify: rename spdk_notify_get_events to spdk_notify_foreach_event
And change type name of callback as well. The new name is more accurate.

Change-Id: I13b63f7d33f60ecea7fdf6e50f57aa6a391a4562
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453151
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-05-07 06:11:27 +00:00

1.8 KiB

Notify library

The notify library implements an event bus, allowing users to register, generate, and listen for events. For example, the bdev library may register a new event type for bdev creation. Any time a bdev is created, it "sends" the event. Consumers of that event may periodically poll for new events to retrieve them. The event bus is implemented as a circular ring of fixed size. If event consumers do not poll frequently enough, events may be lost. All events are identified by a monotonically increasing integer, so missing events may be detected, although not recovered.

Register event types

During initialization the sender library should register its own event types using spdk_notify_type_register(const char *type). Parameter 'type' is the name of notification type.

Get info about events

A consumer can get information about the available event types during runtime using spdk_notify_foreach_type, which iterates over registered notification types and calls a callback on each of them, so that user can produce detailed information about notification.

Get new events

A consumer can get events by calling function spdk_notify_foreach_event. The caller should specify last received event and the maximum number of invocations. There might be multiple consumers of each event. The event bus is implemented as a circular buffer, so older events may be overwritten by newer ones.

Send events

When an event occurs, a library can invoke spdk_notify_send with two strings. One containing the type of the event, like "spdk_bdev_register", second with context, for example "Nvme0n1"

RPC Calls

See JSON-RPC documentation