1 .TH "event2/rpc.h" 3 "Tue Jan 27 2015" "libevent" \" -*- nroff -*-
7 This header files provides basic support for an RPC server and client\&.
16 .RI "#define \fBEVRPC_GENERATE\fP(rpcname, reqstruct, rplystruct)"
18 .RI "\fIGenerates the code for receiving and sending an RPC message\&. \fP"
20 .RI "#define \fBEVRPC_HEADER\fP(rpcname, reqstruct, rplystruct)"
22 .RI "\fICreates the definitions and prototypes for an RPC\&. \fP"
24 .RI "#define \fBEVRPC_MAKE_CTX\fP(rpcname, reqstruct, rplystruct, pool, request, reply, cb, cbarg)"
26 .RI "\fICreates a context structure that contains rpc specific information\&. \fP"
28 .RI "#define \fBEVRPC_MAKE_REQUEST\fP(name, pool, request, reply, cb, cbarg) evrpc_send_request_##name((pool), (request), (reply), (cb), (cbarg))"
30 .RI "\fIlaunches an RPC and sends it to the server \fP"
32 .RI "#define \fBEVRPC_REGISTER\fP(base, name, request, reply, callback, cbarg)"
34 .RI "\fIregister RPCs with the HTTP Server \fP"
36 .RI "#define \fBEVRPC_REQUEST_DONE\fP(rpc_req)"
38 .RI "\fICreates the reply to an RPC request\&. \fP"
40 .RI "#define \fBEVRPC_REQUEST_HTTP\fP(rpc_req) (rpc_req)->http_req"
42 .RI "\fIProvides access to the HTTP request object underlying an RPC\&. \fP"
44 .RI "#define \fBEVRPC_STRUCT\fP(rpcname) struct evrpc_req__##rpcname"
46 .RI "\fIThe type of a specific RPC Message\&. \fP"
48 .RI "#define \fBEVRPC_UNREGISTER\fP(base, name) evrpc_unregister_rpc((base), #name)"
50 .RI "\fIUnregisters an already registered RPC\&. \fP"
52 .RI "#define \fBEVTAG_ARRAY_ADD\fP(msg, member) (*(msg)->base->member##_add)(msg)"
54 .RI "\fIAllocates a new entry in the array and returns it\&. \fP"
56 .RI "#define \fBEVTAG_ARRAY_ADD_VALUE\fP(msg, member, value) (*(msg)->base->member##_add)((msg), (value))"
58 .RI "\fIAdds a value to an array\&. \fP"
60 .RI "#define \fBEVTAG_ARRAY_GET\fP(msg, member, offset, pvalue) (*(msg)->base->member##_get)((msg), (offset), (pvalue))"
62 .RI "\fIGets a variable at the specified offset from the array\&. \fP"
64 .RI "#define \fBEVTAG_ARRAY_LEN\fP(msg, member) ((msg)->member##_length)"
66 .RI "\fIReturns the number of entries in the array\&. \fP"
68 .RI "#define \fBEVTAG_ASSIGN\fP(msg, member, value) (*(msg)->base->member##_assign)((msg), (value))"
70 .RI "\fIAssigns a value to the member in the message\&. \fP"
72 .RI "#define \fBEVTAG_ASSIGN_WITH_LEN\fP(msg, member, value, len) (*(msg)->base->member##_assign)((msg), (value), (len))"
74 .RI "\fIAssigns a value to the member in the message\&. \fP"
76 .RI "#define \fBEVTAG_GET\fP(msg, member, pvalue) (*(msg)->base->member##_get)((msg), (pvalue))"
78 .RI "\fIReturns the value for a member\&. \fP"
80 .RI "#define \fBEVTAG_GET_WITH_LEN\fP(msg, member, pvalue, plen) (*(msg)->base->member##_get)((msg), (pvalue), (plen))"
82 .RI "\fIReturns the value for a member\&. \fP"
84 .RI "#define \fBEVTAG_HAS\fP(msg, member) ((msg)->member##_set == 1)"
86 .RI "\fIDetermines if the member has been set in the message\&. \fP"
88 .RI "#define \fBINPUT\fP \fBEVRPC_INPUT\fP"
90 .RI "\fIDeprecated alias for EVRPC_INPUT\&. \fP"
92 .RI "#define \fBOUTPUT\fP \fBEVRPC_OUTPUT\fP"
94 .RI "\fIDeprecated alias for EVRPC_OUTPUT\&. \fP"
100 .RI "enum \fBEVRPC_HOOK_RESULT\fP { \fBEVRPC_TERMINATE\fP = -1, \fBEVRPC_CONTINUE\fP = 0, \fBEVRPC_PAUSE\fP = 1 }"
102 .RI "\fIReturn value from hook processing functions\&. \fP"
104 .RI "enum \fBEVRPC_HOOK_TYPE\fP { \fBEVRPC_INPUT\fP, \fBEVRPC_OUTPUT\fP }"
106 .RI "\fIHooks for changing the input and output of RPCs; this can be used to implement compression, authentication, encryption, \&.\&.\&. \fP"
112 .RI "void * \fBevrpc_add_hook\fP (void *vbase, enum \fBEVRPC_HOOK_TYPE\fP hook_type, int(*cb)(void *, struct evhttp_request *, struct \fBevbuffer\fP *, void *), void *cb_arg)"
114 .RI "\fIadds a processing hook to either an rpc base or rpc pool \fP"
116 .RI "void \fBevrpc_free\fP (struct evrpc_base *base)"
118 .RI "\fIFrees the evrpc base\&. \fP"
120 .RI "void * \fBevrpc_get_reply\fP (struct evrpc_req_generic *req)"
123 .RI "void * \fBevrpc_get_request\fP (struct evrpc_req_generic *req)"
125 .RI "\fIaccessors for request and reply \fP"
127 .RI "void \fBevrpc_hook_add_meta\fP (void *ctx, const char *key, const void *data, size_t data_size)"
129 .RI "\fIadds meta data to request \fP"
131 .RI "int \fBevrpc_hook_find_meta\fP (void *ctx, const char *key, void **data, size_t *data_size)"
133 .RI "\fIretrieves meta data previously associated \fP"
135 .RI "struct evhttp_connection * \fBevrpc_hook_get_connection\fP (void *ctx)"
137 .RI "\fIreturns the connection object associated with the request \fP"
139 .RI "struct evrpc_base * \fBevrpc_init\fP (struct evhttp *server)"
141 .RI "\fICreates a new rpc base from which RPC requests can be received\&. \fP"
143 .RI "int \fBevrpc_make_request\fP (struct evrpc_request_wrapper *ctx)"
145 .RI "\fIMakes an RPC request based on the provided context\&. \fP"
147 .RI "struct evrpc_request_wrapper * \fBevrpc_make_request_ctx\fP (struct evrpc_pool *pool, void *request, void *reply, const char *rpcname, void(*req_marshal)(struct \fBevbuffer\fP *, void *), void(*rpl_clear)(void *), int(*rpl_unmarshal)(void *, struct \fBevbuffer\fP *), void(*cb)(struct evrpc_status *, void *, void *, void *), void *cbarg)"
149 .RI "\fIuse EVRPC_GENERATE instead \fP"
151 .RI "void \fBevrpc_pool_add_connection\fP (struct evrpc_pool *pool, struct evhttp_connection *evcon)"
153 .RI "\fIAdds a connection over which rpc can be dispatched to the pool\&. \fP"
155 .RI "void \fBevrpc_pool_free\fP (struct evrpc_pool *pool)"
157 .RI "\fIfrees an rpc connection pool \fP"
159 .RI "struct evrpc_pool * \fBevrpc_pool_new\fP (struct \fBevent_base\fP *base)"
161 .RI "\fIcreates an rpc connection pool \fP"
163 .RI "void \fBevrpc_pool_remove_connection\fP (struct evrpc_pool *pool, struct evhttp_connection *evcon)"
165 .RI "\fIRemoves a connection from the pool\&. \fP"
167 .RI "void \fBevrpc_pool_set_timeout\fP (struct evrpc_pool *pool, int timeout_in_secs)"
169 .RI "\fISets the timeout in secs after which a request has to complete\&. \fP"
171 .RI "int \fBevrpc_register_generic\fP (struct evrpc_base *base, const char *name, void(*callback)(struct evrpc_req_generic *, void *), void *cbarg, void *(*req_new)(void *), void *req_new_arg, void(*req_free)(void *), int(*req_unmarshal)(void *, struct \fBevbuffer\fP *), void *(*rpl_new)(void *), void *rpl_new_arg, void(*rpl_free)(void *), int(*rpl_complete)(void *), void(*rpl_marshal)(struct \fBevbuffer\fP *, void *))"
173 .RI "\fIFunction for registering a generic RPC with the RPC base\&. \fP"
175 .RI "int \fBevrpc_register_rpc\fP (struct evrpc_base *, struct evrpc *, void(*)(struct evrpc_req_generic *, void *), void *)"
177 .RI "\fILow level function for registering an RPC with a server\&. \fP"
179 .RI "int \fBevrpc_remove_hook\fP (void *vbase, enum \fBEVRPC_HOOK_TYPE\fP hook_type, void *handle)"
181 .RI "\fIremoves a previously added hook \fP"
183 .RI "void \fBevrpc_request_done\fP (struct evrpc_req_generic *req)"
185 .RI "\fIcompletes the server response to an rpc request \fP"
187 .RI "struct evrpc_pool * \fBevrpc_request_get_pool\fP (struct evrpc_request_wrapper *ctx)"
189 .RI "\fIaccessors for obscure and undocumented functionality \fP"
191 .RI "void \fBevrpc_request_set_cb\fP (struct evrpc_request_wrapper *ctx, void(*cb)(struct evrpc_status *, void *request, void *reply, void *arg), void *cb_arg)"
194 .RI "void \fBevrpc_request_set_pool\fP (struct evrpc_request_wrapper *ctx, struct evrpc_pool *pool)"
197 .RI "int \fBevrpc_resume_request\fP (void *vbase, void *ctx, enum \fBEVRPC_HOOK_RESULT\fP res)"
199 .RI "\fIresume a paused request \fP"
201 .RI "int \fBevrpc_send_request_generic\fP (struct evrpc_pool *pool, void *request, void *reply, void(*cb)(struct evrpc_status *, void *, void *, void *), void *cb_arg, const char *rpcname, void(*req_marshal)(struct \fBevbuffer\fP *, void *), void(*rpl_clear)(void *), int(*rpl_unmarshal)(void *, struct \fBevbuffer\fP *))"
203 .RI "\fIFunction for sending a generic RPC request\&. \fP"
205 .RI "int \fBevrpc_unregister_rpc\fP (struct evrpc_base *base, const char *name)"
208 .SH "Detailed Description"
210 This header files provides basic support for an RPC server and client\&.
212 To support RPCs in a server, every supported RPC command needs to be defined and registered\&.
214 \fBEVRPC_HEADER(SendCommand, Request, Reply)\fP;
216 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\&.
218 To register an RPC with an HTTP server, you need to first create an RPC base with:
220 struct evrpc_base *base = evrpc_init(http);
222 A specific RPC can then be registered with
224 \fBEVRPC_REGISTER(base, SendCommand, Request, Reply, FunctionCB, arg)\fP;
226 when the server receives an appropriately formatted RPC, the user callback is invoked\&. The callback needs to fill in the reply structure\&.
228 void FunctionCB(EVRPC_STRUCT(SendCommand)* rpc, void *arg);
230 To send the reply, call \fBEVRPC_REQUEST_DONE(rpc)\fP;
232 See the regression test for an example\&.
233 .SH "Macro Definition Documentation"
235 .SS "#define EVRPC_GENERATE(rpcname, reqstruct, rplystruct)"
239 int evrpc_send_request_##rpcname(struct evrpc_pool *pool, \
240 struct reqstruct *request, struct rplystruct *reply, \
241 void (*cb)(struct evrpc_status *, \
242 struct reqstruct *, struct rplystruct *, void *cbarg), \
244 return evrpc_send_request_generic(pool, request, reply, \
245 (void (*)(struct evrpc_status *, void *, void *, void *))cb, \
248 (void (*)(struct evbuffer *, void *))reqstruct##_marshal, \
249 (void (*)(void *))rplystruct##_clear, \
250 (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal); \
254 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
258 \fIrpcname\fP the name of the RPC
260 \fIreqstruct\fP the name of the RPC request structure
262 \fIreplystruct\fP the name of the RPC reply structure
271 .SS "#define EVRPC_HEADER(rpcname, reqstruct, rplystruct)"
275 EVRPC_STRUCT(rpcname) { \
276 struct evrpc_hook_meta *hook_meta; \
277 struct reqstruct* request; \
278 struct rplystruct* reply; \
280 struct evhttp_request* http_req; \
281 struct evbuffer* rpc_data; \
283 int evrpc_send_request_##rpcname(struct evrpc_pool *, \
284 struct reqstruct *, struct rplystruct *, \
285 void (*)(struct evrpc_status *, \
286 struct reqstruct *, struct rplystruct *, void *cbarg), \
290 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
294 \fIrpcname\fP the name of the RPC
296 \fIreqstruct\fP the name of the RPC request structure
298 \fIreplystruct\fP the name of the RPC reply structure
303 \fBEVRPC_GENERATE()\fP
307 .SS "#define EVRPC_MAKE_CTX(rpcname, reqstruct, rplystruct, pool, request, reply, cb, cbarg)"
311 evrpc_make_request_ctx(pool, request, reply, \
313 (void (*)(struct evbuffer *, void *))reqstruct##_marshal, \
314 (void (*)(void *))rplystruct##_clear, \
315 (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal, \
316 (void (*)(struct evrpc_status *, void *, void *, void *))cb, \
320 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\&.
324 \fIrpcname\fP the name of the RPC
326 \fIreqstruct\fP the name of the RPC request structure
328 \fIreplystruct\fP the name of the RPC reply structure
330 \fIpool\fP the evrpc_pool over which to make the request
332 \fIrequest\fP a pointer to the RPC request structure object
334 \fIreply\fP a pointer to the RPC reply structure object
336 \fIcb\fP the callback function to call when the RPC has completed
338 \fIcbarg\fP the argument to supply to the callback
342 .SS "#define EVRPC_MAKE_REQUEST(name, pool, request, reply, cb, cbarg) evrpc_send_request_##name((pool), (request), (reply), (cb), (cbarg))"
345 launches an RPC and sends it to the server \fBEVRPC_MAKE_REQUEST()\fP is used by the client to send an RPC to the server\&.
349 \fIname\fP the name of the RPC
351 \fIpool\fP the evrpc_pool that contains the connection objects over which the request should be sent\&.
353 \fIrequest\fP a pointer to the RPC request structure - it contains the data to be sent to the server\&.
355 \fIreply\fP a pointer to the RPC reply structure\&. It is going to be filled if the request was answered successfully
357 \fIcb\fP the callback to invoke when the RPC request has been answered
359 \fIcbarg\fP an additional argument to be passed to the client
364 0 on success, -1 on failure
368 .SS "#define EVRPC_REGISTER(base, name, request, reply, callback, cbarg)"
372 evrpc_register_generic(base, #name, \
373 (void (*)(struct evrpc_req_generic *, void *))callback, cbarg, \
374 (void *(*)(void *))request##_new, NULL, \
375 (void (*)(void *))request##_free, \
376 (int (*)(void *, struct evbuffer *))request##_unmarshal, \
377 (void *(*)(void *))reply##_new, NULL, \
378 (void (*)(void *))reply##_free, \
379 (int (*)(void *))reply##_complete, \
380 (void (*)(struct evbuffer *, void *))reply##_marshal)
383 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\&.
387 \fIbase\fP the evrpc_base structure in which the RPC should be registered\&.
389 \fIname\fP the name of the RPC
391 \fIrequest\fP the name of the RPC request structure
393 \fIreply\fP the name of the RPC reply structure
395 \fIcallback\fP the callback that should be invoked when the RPC is received\&. The callback has the following prototype void (\fIcallback)(\fBEVRPC_STRUCT(Message)\fP\fP rpc, void *arg)
397 \fIcbarg\fP an additional parameter that can be passed to the callback\&. The parameter can be used to carry around state\&.
401 .SS "#define EVRPC_REQUEST_DONE(rpc_req)"
406 struct evrpc_req_generic *_req = (struct evrpc_req_generic *)(rpc_req); \\
407 evrpc_request_done(_req); \
411 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\&.
415 \fIrpc_req\fP the rpc request structure provided to the server callback
419 .SS "#define EVRPC_REQUEST_HTTP(rpc_req) (rpc_req)->http_req"
422 Provides access to the HTTP request object underlying an RPC\&. Access to the underlying http object; can be used to look at headers or for getting the remote ip address
426 \fIrpc_req\fP the rpc request structure provided to the server callback
431 an struct evhttp_request object that can be inspected for HTTP headers or sender information\&.
435 .SS "#define EVRPC_STRUCT(rpcname) struct evrpc_req__##rpcname"
438 The type of a specific RPC Message\&.
442 \fIrpcname\fP the name of the RPC message
446 .SS "#define EVRPC_UNREGISTER(base, name) evrpc_unregister_rpc((base), #name)"
449 Unregisters an already registered RPC\&.
453 \fIbase\fP the evrpc_base object from which to unregister an RPC
455 \fIname\fP the name of the rpc to unregister
460 -1 on error or 0 when successful\&.
465 \fBEVRPC_REGISTER()\fP
469 .SS "#define EVTAG_ASSIGN(msg, member, value) (*(msg)->base->member##_assign)((msg), (value))"
472 Assigns a value to the member in the message\&.
476 \fImsg\fP the message to which to assign a value
478 \fImember\fP the name of the member variable
480 \fIvalue\fP the value to assign
484 .SS "#define EVTAG_ASSIGN_WITH_LEN(msg, member, value, len) (*(msg)->base->member##_assign)((msg), (value), (len))"
487 Assigns a value to the member in the message\&.
491 \fImsg\fP the message to which to assign a value
493 \fImember\fP the name of the member variable
495 \fIvalue\fP the value to assign
497 \fIlen\fP the length of the value
501 .SS "#define EVTAG_GET(msg, member, pvalue) (*(msg)->base->member##_get)((msg), (pvalue))"
504 Returns the value for a member\&.
508 \fImsg\fP the message from which to get the value
510 \fImember\fP the name of the member variable
512 \fIpvalue\fP a pointer to the variable to hold the value
517 0 on success, -1 otherwise\&.
521 .SS "#define EVTAG_GET_WITH_LEN(msg, member, pvalue, plen) (*(msg)->base->member##_get)((msg), (pvalue), (plen))"
524 Returns the value for a member\&.
528 \fImsg\fP the message from which to get the value
530 \fImember\fP the name of the member variable
532 \fIpvalue\fP a pointer to the variable to hold the value
534 \fIplen\fP a pointer to the length of the value
539 0 on success, -1 otherwise\&.
543 .SS "#define EVTAG_HAS(msg, member) ((msg)->member##_set == 1)"
546 Determines if the member has been set in the message\&.
550 \fImsg\fP the message to inspect
552 \fImember\fP the member variable to test for presences
557 1 if it's present or 0 otherwise\&.
561 .SS "#define INPUT \fBEVRPC_INPUT\fP"
564 Deprecated alias for EVRPC_INPUT\&. Not available on windows, where it conflicts with platform headers\&.
565 .SS "#define OUTPUT \fBEVRPC_OUTPUT\fP"
568 Deprecated alias for EVRPC_OUTPUT\&. Not available on windows, where it conflicts with platform headers\&.
569 .SH "Enumeration Type Documentation"
571 .SS "enum \fBEVRPC_HOOK_RESULT\fP"
574 Return value from hook processing functions\&.
579 \fB\fIEVRPC_TERMINATE \fP\fP
580 indicates the rpc should be terminated
582 \fB\fIEVRPC_CONTINUE \fP\fP
583 continue processing the rpc
585 \fB\fIEVRPC_PAUSE \fP\fP
586 pause processing request until resumed
587 .SS "enum \fBEVRPC_HOOK_TYPE\fP"
590 Hooks for changing the input and output of RPCs; this can be used to implement compression, authentication, encryption, \&.\&.\&.
595 \fB\fIEVRPC_INPUT \fP\fP
596 apply the function to an input hook
598 \fB\fIEVRPC_OUTPUT \fP\fP
599 apply the function to an output hook
600 .SH "Function Documentation"
602 .SS "void* evrpc_add_hook (void *vbase, enum \fBEVRPC_HOOK_TYPE\fPhook_type, int(*)(void *, struct evhttp_request *, struct \fBevbuffer\fP *, void *)cb, void *cb_arg)"
605 adds a processing hook to either an rpc base or rpc pool If a hook returns TERMINATE, the processing is aborted\&. On CONTINUE, the request is immediately processed after the hook returns\&. If the hook returns PAUSE, request processing stops until \fBevrpc_resume_request()\fP has been called\&.
607 The add functions return handles that can be used for removing hooks\&.
611 \fIvbase\fP a pointer to either struct evrpc_base or struct evrpc_pool
613 \fIhook_type\fP either INPUT or OUTPUT
615 \fIcb\fP the callback to call when the hook is activated
617 \fIcb_arg\fP an additional argument for the callback
622 a handle to the hook so it can be removed later
627 \fBevrpc_remove_hook()\fP
631 .SS "void evrpc_free (struct evrpc_base *base)"
634 Frees the evrpc base\&. For now, you are responsible for making sure that no rpcs are ongoing\&.
638 \fIbase\fP the evrpc_base object to be freed
647 .SS "void evrpc_hook_add_meta (void *ctx, const char *key, const void *data, size_tdata_size)"
650 adds meta data to request \fBevrpc_hook_add_meta()\fP allows hooks to add meta data to a request\&. for a client request, the meta data can be inserted by an outgoing request hook and retrieved by the incoming request hook\&.
654 \fIctx\fP the context provided to the hook call
656 \fIkey\fP a NUL-terminated c-string
658 \fIdata\fP the data to be associated with the key
660 \fIdata_size\fP the size of the data
664 .SS "int evrpc_hook_find_meta (void *ctx, const char *key, void **data, size_t *data_size)"
667 retrieves meta data previously associated \fBevrpc_hook_find_meta()\fP can be used to retrieve meta data associated to a request by a previous hook\&.
671 \fIctx\fP the context provided to the hook call
673 \fIkey\fP a NUL-terminated c-string
675 \fIdata\fP pointer to a data pointer that will contain the retrieved data
677 \fIdata_size\fP pointer to the size of the data
682 0 on success or -1 on failure
686 .SS "struct evhttp_connection* evrpc_hook_get_connection (void *ctx)"
689 returns the connection object associated with the request
693 \fIctx\fP the context provided to the hook call
698 a pointer to the evhttp_connection object
702 .SS "struct evrpc_base* evrpc_init (struct evhttp *server)"
705 Creates a new rpc base from which RPC requests can be received\&.
709 \fIserver\fP a pointer to an existing HTTP server
714 a newly allocated evrpc_base struct
723 .SS "int evrpc_make_request (struct evrpc_request_wrapper *ctx)"
726 Makes an RPC request based on the provided context\&. This is a low-level function and should not be used directly unless a custom context object is provided\&. Use \fBEVRPC_MAKE_REQUEST()\fP instead\&.
730 \fIctx\fP a context from \fBEVRPC_MAKE_CTX()\fP
735 0 on success, -1 otherwise\&.
740 \fBEVRPC_MAKE_REQUEST()\fP, \fBEVRPC_MAKE_CTX()\fP
744 .SS "void evrpc_pool_add_connection (struct evrpc_pool *pool, struct evhttp_connection *evcon)"
747 Adds a connection over which rpc can be dispatched to the pool\&. The connection object must have been newly created\&.
751 \fIpool\fP the pool to which to add the connection
753 \fIevcon\fP the connection to add to the pool\&.
757 .SS "void evrpc_pool_free (struct evrpc_pool *pool)"
760 frees an rpc connection pool
764 \fIpool\fP a pointer to an evrpc_pool allocated via \fBevrpc_pool_new()\fP
769 \fBevrpc_pool_new()\fP
773 .SS "struct evrpc_pool* evrpc_pool_new (struct \fBevent_base\fP *base)"
776 creates an rpc connection pool a pool has a number of connections associated with it\&. rpc requests are always made via a pool\&.
780 \fIbase\fP a pointer to an struct event_based object; can be left NULL in singled-threaded applications
785 a newly allocated struct evrpc_pool object
790 \fBevrpc_pool_free()\fP
794 .SS "void evrpc_pool_remove_connection (struct evrpc_pool *pool, struct evhttp_connection *evcon)"
797 Removes a connection from the pool\&. The connection object must have been newly created\&.
801 \fIpool\fP the pool from which to remove the connection
803 \fIevcon\fP the connection to remove from the pool\&.
807 .SS "void evrpc_pool_set_timeout (struct evrpc_pool *pool, inttimeout_in_secs)"
810 Sets the timeout in secs after which a request has to complete\&. The RPC is completely aborted if it does not complete by then\&. Setting the timeout to 0 means that it never timeouts and can be used to implement callback type RPCs\&.
812 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\&.
816 \fIpool\fP a pointer to a struct evrpc_pool object
818 \fItimeout_in_secs\fP the number of seconds after which a request should timeout and a failure be returned to the callback\&.
822 .SS "int evrpc_register_generic (struct evrpc_base *base, const char *name, void(*)(struct evrpc_req_generic *, void *)callback, void *cbarg, void *(*)(void *)req_new, void *req_new_arg, void(*)(void *)req_free, int(*)(void *, struct \fBevbuffer\fP *)req_unmarshal, void *(*)(void *)rpl_new, void *rpl_new_arg, void(*)(void *)rpl_free, int(*)(void *)rpl_complete, void(*)(struct \fBevbuffer\fP *, void *)rpl_marshal)"
825 Function for registering a generic RPC with the RPC base\&. Do not call this function directly, use \fBEVRPC_REGISTER()\fP instead\&.
829 \fBEVRPC_REGISTER()\fP
833 .SS "int evrpc_register_rpc (struct evrpc_base *, struct evrpc *, void(*)(struct evrpc_req_generic *, void *), void *)"
836 Low level function for registering an RPC with a server\&. Use \fBEVRPC_REGISTER()\fP instead\&.
840 \fBEVRPC_REGISTER()\fP
844 .SS "int evrpc_remove_hook (void *vbase, enum \fBEVRPC_HOOK_TYPE\fPhook_type, void *handle)"
847 removes a previously added hook
851 \fIvbase\fP a pointer to either struct evrpc_base or struct evrpc_pool
853 \fIhook_type\fP either INPUT or OUTPUT
855 \fIhandle\fP a handle returned by \fBevrpc_add_hook()\fP
860 1 on success or 0 on failure
865 \fBevrpc_add_hook()\fP
869 .SS "int evrpc_resume_request (void *vbase, void *ctx, enum \fBEVRPC_HOOK_RESULT\fPres)"
872 resume a paused request
876 \fIvbase\fP a pointer to either struct evrpc_base or struct evrpc_pool
878 \fIctx\fP the context pointer provided to the original hook call
882 .SS "int evrpc_send_request_generic (struct evrpc_pool *pool, void *request, void *reply, void(*)(struct evrpc_status *, void *, void *, void *)cb, void *cb_arg, const char *rpcname, void(*)(struct \fBevbuffer\fP *, void *)req_marshal, void(*)(void *)rpl_clear, int(*)(void *, struct \fBevbuffer\fP *)rpl_unmarshal)"
885 Function for sending a generic RPC request\&. Do not call this function directly, use \fBEVRPC_MAKE_REQUEST()\fP instead\&.
889 \fBEVRPC_MAKE_REQUEST()\fP
895 Generated automatically by Doxygen for libevent from the source code\&.