evrpc(3) | Library Functions Manual | evrpc(3) |
This header files provides basic support for an RPC server and client.
EVRPC_HEADER(SendCommand, Request, Reply);
SendCommand is the name of the RPC command. Request is the name of a structure generated by event_rpcgen.py. It contains all parameters relating to the SendCommand RPC. The server needs to fill in the Reply structure. Reply is the name of a structure generated by event_rpcgen.py. It contains the answer to the RPC.
To register an RPC with an HTTP server, you need to first create an RPC base with:
struct evrpc_base *base = evrpc_init(http);
A specific RPC can then be registered with
EVRPC_REGISTER(base, SendCommand, Request, Reply, FunctionCB, arg);
when the server receives an appropriately formatted RPC, the user callback is invoked. The callback needs to fill in the reply structure.
void FunctionCB(EVRPC_STRUCT(SendCommand)* rpc, void *arg);
To send the reply, call EVRPC_REQUEST_DONE(rpc);
See the regression test for an example.
int evrpc_send_request_##rpcname(struct evrpc_pool *pool, struct reqstruct *request, struct rplystruct *reply, void (*cb)(struct evrpc_status *, struct reqstruct *, struct rplystruct *, void *cbarg), void *cbarg) { return evrpc_send_request_generic(pool, request, reply, (void (*)(struct evrpc_status *, void *, void *, void *))cb, cbarg, #rpcname, (void (*)(struct evbuffer *, void *))reqstruct##_marshal, (void (*)(void *))rplystruct##_clear, (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal); }
Generates the code for receiving and sending an RPC message. EVRPC_GENERATE is used to create the code corresponding to sending and receiving a particular RPC message
Parameters:
See Also:
EVRPC_STRUCT(rpcname) { struct evrpc_hook_meta *hook_meta; struct reqstruct* request; struct rplystruct* reply; struct evrpc* rpc; struct evhttp_request* http_req; struct evbuffer* rpc_data; }; int evrpc_send_request_##rpcname(struct evrpc_pool *, struct reqstruct *, struct rplystruct *, void (*)(struct evrpc_status *, struct reqstruct *, struct rplystruct *, void *cbarg), void *);
Creates the definitions and prototypes for an RPC. You need to use EVRPC_HEADER to create structures and function prototypes needed by the server and client implementation. The structures have to be defined in an .rpc file and converted to source code via event_rpcgen.py
Parameters:
See Also:
evrpc_make_request_ctx(pool, request, reply, #rpcname, (void (*)(struct evbuffer *, void *))reqstruct##_marshal, (void (*)(void *))rplystruct##_clear, (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal, (void (*)(struct evrpc_status *, void *, void *, void *))cb, cbarg)
Creates a context structure that contains rpc specific information. EVRPC_MAKE_CTX is used to populate a RPC specific context that contains information about marshaling the RPC data types.
Parameters:
Parameters:
Returns:
evrpc_register_generic(base, #name, (void (*)(struct evrpc_req_generic *, void *))callback, cbarg, (void *(*)(void *))request##_new, NULL, (void (*)(void *))request##_free, (int (*)(void *, struct evbuffer *))request##_unmarshal, (void *(*)(void *))reply##_new, NULL, (void (*)(void *))reply##_free, (int (*)(void *))reply##_complete, (void (*)(struct evbuffer *, void *))reply##_marshal)
register RPCs with the HTTP Server registers a new RPC with the HTTP server, each RPC needs to have a unique name under which it can be identified.
Parameters:
do { struct evrpc_req_generic *_req = (struct evrpc_req_generic *)(rpc_req); evrpc_request_done(_req); } while (/*CONSTCOND*/0)
Creates the reply to an RPC request. EVRPC_REQUEST_DONE is used to answer a request; the reply is expected to have been filled in. The request and reply pointers become invalid after this call has finished.
Parameters:
Parameters:
Returns:
Returns:
See Also:
Returns:
Returns:
Returns:
Enumerator
Enumerator
The add functions return handles that can be used for removing hooks.
Parameters:
Returns:
See Also:
Parameters:
See Also:
Parameters:
Parameters:
Returns:
Returns:
Returns:
See Also:
Parameters:
Returns:
See Also:
Parameters:
See Also:
Parameters:
Returns:
See Also:
Parameters:
Any connection already in the pool will be updated with the new timeout. Connections added to the pool after set_timeout has be called receive the pool timeout only if no timeout has been set for the connection itself.
Parameters:
See Also:
See Also:
Returns:
See Also:
See Also:
Wed Apr 10 2013 | libevent |