| Mercury Monitor Reference Manual |
|---|
Module SupportModule Support — Support for producer-side protocol modules |
#include <monitor/producer/modules.h> enum prod_module_type; #define PROD_SYMBOL_PROTOCOL #define PROD_PROTOCOL_MODULE (desc) #define PROD_PROTOCOL_API prod_proto_module; prod_proto_state; int prod_proto_register (mon_module *module); void prod_proto_unregister (mon_module *module); prod_proto_module* prod_proto_get (const char *name); void prod_proto_done (prod_proto_module *proto); void prod_proto_ref (prod_proto_module *proto);
typedef enum {
PROD_MODULE_DSO,
PROD_MODULE_MALLOC,
PROD_MODULE_BUILTIN
} prod_module_type;
Types of modules handled by the producer.
| PROD_MODULE_DSO | this is a module loaded dynamically. |
| PROD_MODULE_MALLOC | this is a module allocated by g_malloc(). It is used for representing modules accessible through RPC. |
| PROD_MODULE_BUILTIN | this is a module built in statically. |
#define PROD_SYMBOL_PROTOCOL MON_MODSYM(prod_module_protocol)
Defines the symbol name of the protocol module descriptor table in a loadable module.
#define PROD_PROTOCOL_MODULE(desc)
Declares a protocol module.
| desc : | the name of the prod_proto_module descriptor. |
#define PROD_PROTOCOL_API 2
Defines the protocol API version implemented by the library.
typedef struct {
mon_module header;
int def_port;
prod_proto_state *(*init)(prod_conn *conn,
mon_bio_head *bh);
void (*destroy)(prod_proto_state *state);
int (*get_command)(prod_proto_state *state,
mon_bio_head *bh,
prod_cmd **cmd);
int (*send_msg)(prod_proto_state *state,
mon_bio_head *bh,
prod_msg *msg);
} prod_proto_module;
Describes a producer-side protocol module.
| mon_module header; | the general module header. |
| int def_port; | the default port to listen on. |
| init () | initialize the internal protocol state. |
| destroy () | destroy the internal protocol state. |
| get_command () | function to retrieve the next command sent by a consumer. |
| send_msg () | function to encode a message generated by the producer. |
typedef struct _prod_proto_state prod_proto_state;
Opaque structure used by the protcol encoding module to store internal state information about the protocol encoding.
int prod_proto_register (mon_module *module);
Registers a protocol module.
| module : | a prod_proto_module to register. |
| Returns : | 0 if successful or an error code. |
void prod_proto_unregister (mon_module *module);
Unregisters a protocol module.
| module : | a prod_proto_module to unregister. |
prod_proto_module* prod_proto_get (const char *name);
Returns the module descriptor for a protocol name.
| name : | the name of the protocol. |
| Returns : | a prod_proto_module or NULL if name is not known. |
void prod_proto_done (prod_proto_module *proto);
Decrements the reference count of a prod_proto_module. If the reference count reaches zero, the module is unloaded.
| proto : | a prod_proto_module. |
void prod_proto_ref (prod_proto_module *proto);
Increments the reference count of a prod_proto_module.
| proto : | a prod_proto_module. |
| << Filters | Asynchronous registry interface >> |