Motr
M0
|
Configuration client library – confc – provides user-space and kernel interfaces for accessing Motr configuration information.
Confc obtains configuration data from network-accessible configuration server (confd) and caches this data in memory.
Prior to accessing configuration, the application (aka configuration consumer) should initialise configuration client by calling m0_confc_init().
A confc instance is associated with a state machine group (m0_sm_group). A user managing this group is responsible for making sure m0_sm_asts_run() is called when the group's channel is signaled; "AST" section of State machine has more details on this topic.
m0_confc_fini() terminates confc, destroying configuration cache.
The application gets access to configuration data by opening configuration objects with m0_confc_open() or m0_confc_open_sync(). Directory objects can be iterated over with m0_confc_readdir() or m0_confc_readdir_sync().
m0_confc_open() and m0_confc_readdir() are asynchronous functions. Prior to calling them, the application should initialise a context object (m0_confc_ctx_init()) and register a clink with .sm_chan member of m0_confc_ctx::fc_mach. (See sm_waiter_init() in the recipe #1 below.)
m0_confc_ctx_is_completed() checks whether configuration retrieval has completed, i.e., terminated or failed.
m0_confc_ctx_error() returns the error status of an asynchronous configuration retrieval operation. m0_confc_ctx_result() returns the requested configuration object.
A caller of m0_confc_open_sync() or m0_confc_readdir_sync() will be blocked while confc is processing the request.
All m0_confc_open*()ed configuration objects must be m0_confc_close()ed before m0_confc_fini() is called.
m0_conf_diter_next() is an asynchronous function. Prior to invoking it, the application must invoke m0_conf_diter_wait_arm() and register a clink to receive the completion event. Result of the iteration must be accessed using m0_conf_diter_result().
Configuration objects can be opened asynchronously (m0_confc_open()) or synchronously (m0_confc_open_sync()). Many of the examples below use synchronous calls for the sake of brevity.