27 #ifndef _EVENT2_RPC_H_
28 #define _EVENT2_RPC_H_
76 #define EVTAG_HAS(msg, member) \
77 ((msg)->member##_set == 1)
79 #ifndef _EVENT2_RPC_COMPAT_H_
88 #define EVTAG_ASSIGN(msg, member, value) \
89 (*(msg)->base->member##_assign)((msg), (value))
98 #define EVTAG_ASSIGN_WITH_LEN(msg, member, value, len) \
99 (*(msg)->base->member##_assign)((msg), (value), (len))
108 #define EVTAG_GET(msg, member, pvalue) \
109 (*(msg)->base->member##_get)((msg), (pvalue))
119 #define EVTAG_GET_WITH_LEN(msg, member, pvalue, plen) \
120 (*(msg)->base->member##_get)((msg), (pvalue), (plen))
127 #define EVTAG_ARRAY_ADD_VALUE(msg, member, value) \
128 (*(msg)->base->member##_add)((msg), (value))
132 #define EVTAG_ARRAY_ADD(msg, member) \
133 (*(msg)->base->member##_add)(msg)
137 #define EVTAG_ARRAY_GET(msg, member, offset, pvalue) \
138 (*(msg)->base->member##_get)((msg), (offset), (pvalue))
142 #define EVTAG_ARRAY_LEN(msg, member) ((msg)->member##_length)
155 #define EVRPC_STRUCT(rpcname) struct evrpc_req__##rpcname
172 #define EVRPC_HEADER(rpcname, reqstruct, rplystruct) \
173 EVRPC_STRUCT(rpcname) { \
174 struct evrpc_hook_meta *hook_meta; \
175 struct reqstruct* request; \
176 struct rplystruct* reply; \
178 struct evhttp_request* http_req; \
179 struct evbuffer* rpc_data; \
181 int evrpc_send_request_##rpcname(struct evrpc_pool *, \
182 struct reqstruct *, struct rplystruct *, \
183 void (*)(struct evrpc_status *, \
184 struct reqstruct *, struct rplystruct *, void *cbarg), \
193 void (*req_marshal)(
struct evbuffer*,
void *),
194 void (*rpl_clear)(
void *),
195 int (*rpl_unmarshal)(
void *,
struct evbuffer *),
196 void (*cb)(
struct evrpc_status *,
void *,
void *,
void *),
213 #define EVRPC_MAKE_CTX(rpcname, reqstruct, rplystruct, \
214 pool, request, reply, cb, cbarg) \
215 evrpc_make_request_ctx(pool, request, reply, \
217 (void (*)(struct evbuffer *, void *))reqstruct##_marshal, \
218 (void (*)(void *))rplystruct##_clear, \
219 (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal, \
220 (void (*)(struct evrpc_status *, void *, void *, void *))cb, \
233 #define EVRPC_GENERATE(rpcname, reqstruct, rplystruct) \
234 int evrpc_send_request_##rpcname(struct evrpc_pool *pool, \
235 struct reqstruct *request, struct rplystruct *reply, \
236 void (*cb)(struct evrpc_status *, \
237 struct reqstruct *, struct rplystruct *, void *cbarg), \
239 return evrpc_send_request_generic(pool, request, reply, \
240 (void (*)(struct evrpc_status *, void *, void *, void *))cb, \
243 (void (*)(struct evbuffer *, void *))reqstruct##_marshal, \
244 (void (*)(void *))rplystruct##_clear, \
245 (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal); \
257 #define EVRPC_REQUEST_HTTP(rpc_req) (rpc_req)->http_req
274 #define EVRPC_REQUEST_DONE(rpc_req) do { \
275 struct evrpc_req_generic *_req = (struct evrpc_req_generic *)(rpc_req); \
276 evrpc_request_done(_req); \
319 #define EVRPC_REGISTER(base, name, request, reply, callback, cbarg) \
320 evrpc_register_generic(base, #name, \
321 (void (*)(struct evrpc_req_generic *, void *))callback, cbarg, \
322 (void *(*)(void *))request##_new, NULL, \
323 (void (*)(void *))request##_free, \
324 (int (*)(void *, struct evbuffer *))request##_unmarshal, \
325 (void *(*)(void *))reply##_new, NULL, \
326 (void (*)(void *))reply##_free, \
327 (int (*)(void *))reply##_complete, \
328 (void (*)(struct evbuffer *, void *))reply##_marshal)
348 #define EVRPC_UNREGISTER(base, name) evrpc_unregister_rpc((base), #name)
350 int evrpc_unregister_rpc(
struct evrpc_base *base,
const char *name);
374 #define EVRPC_MAKE_REQUEST(name, pool, request, reply, cb, cbarg) \
375 evrpc_send_request_##name((pool), (request), (reply), (cb), (cbarg))
460 #define INPUT EVRPC_INPUT
463 #define OUTPUT EVRPC_OUTPUT
529 const void *data,
size_t data_size);
542 void **data,
size_t *data_size);
560 void *request,
void *reply,
561 void (*cb)(
struct evrpc_status *,
void *,
void *,
void *),
564 void (*req_marshal)(
struct evbuffer *,
void *),
565 void (*rpl_clear)(
void *),
566 int (*rpl_unmarshal)(
void *,
struct evbuffer *));
578 void *(*req_new)(
void *),
void *req_new_arg,
void (*req_free)(
void *),
579 int (*req_unmarshal)(
void *,
struct evbuffer *),
580 void *(*rpl_new)(
void *),
void *rpl_new_arg,
void (*rpl_free)(
void *),
581 int (*rpl_complete)(
void *),
582 void (*rpl_marshal)(
struct evbuffer *,
void *));
589 void (*cb)(
struct evrpc_status*,
void *request,
void *reply,
void *arg),
int evrpc_hook_find_meta(void *ctx, const char *key, void **data, size_t *data_size)
retrieves meta data previously associated
Definition: evrpc.c:1044
int evrpc_register_generic(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 evbuffer *), void *(*rpl_new)(void *), void *rpl_new_arg, void(*rpl_free)(void *), int(*rpl_complete)(void *), void(*rpl_marshal)(struct evbuffer *, void *))
Function for registering a generic RPC with the RPC base.
Definition: evrpc.c:1124
int evrpc_remove_hook(void *vbase, enum EVRPC_HOOK_TYPE hook_type, void *handle)
removes a previously added hook
Definition: evrpc.c:168
pause processing request until resumed
Definition: rpc.h:473
void evrpc_pool_set_timeout(struct evrpc_pool *pool, int timeout_in_secs)
Sets the timeout in secs after which a request has to complete.
Definition: evrpc.c:611
struct evrpc_request_wrapper * evrpc_make_request_ctx(struct evrpc_pool *pool, void *request, void *reply, const char *rpcname, void(*req_marshal)(struct evbuffer *, void *), void(*rpl_clear)(void *), int(*rpl_unmarshal)(void *, struct evbuffer *), void(*cb)(struct evrpc_status *, void *, void *, void *), void *cbarg)
use EVRPC_GENERATE instead
Definition: evrpc.c:814
void * evrpc_get_request(struct evrpc_req_generic *req)
accessors for request and reply
Definition: evrpc.c:454
indicates the rpc should be terminated
Definition: rpc.h:471
Definition: evrpc-internal.h:163
int evrpc_register_rpc(struct evrpc_base *, struct evrpc *, void(*)(struct evrpc_req_generic *, void *), void *)
Low level function for registering an RPC with a server.
Definition: evrpc.c:227
Definition: evrpc-internal.h:71
apply the function to an output hook
Definition: rpc.h:454
void evrpc_pool_add_connection(struct evrpc_pool *pool, struct evhttp_connection *evcon)
Adds a connection over which rpc can be dispatched to the pool.
Definition: evrpc.c:571
void evrpc_free(struct evrpc_base *base)
Frees the evrpc base.
Definition: evrpc.c:92
struct evrpc_base * evrpc_init(struct evhttp *server)
Creates a new rpc base from which RPC requests can be received.
Definition: evrpc.c:71
continue processing the rpc
Definition: rpc.h:472
struct evrpc_pool * evrpc_pool_new(struct event_base *base)
creates an rpc connection pool
Definition: evrpc.c:499
EVRPC_HOOK_TYPE
Hooks for changing the input and output of RPCs; this can be used to implement compression, authentication, encryption, ...
Definition: rpc.h:452
Definition: evbuffer-internal.h:78
void evrpc_request_done(struct evrpc_req_generic *req)
completes the server response to an rpc request
Definition: evrpc.c:400
Definition: evrpc-internal.h:132
void evrpc_pool_remove_connection(struct evrpc_pool *pool, struct evhttp_connection *evcon)
Removes a connection from the pool.
Definition: evrpc.c:604
struct evrpc_pool * evrpc_request_get_pool(struct evrpc_request_wrapper *ctx)
accessors for obscure and undocumented functionality
Definition: evrpc.c:1144
Definition: http-internal.h:62
struct evhttp_connection * evrpc_hook_get_connection(void *ctx)
returns the connection object associated with the request
Definition: evrpc.c:1064
provides information about the completed RPC request.
Definition: rpc_struct.h:44
void evrpc_hook_add_meta(void *ctx, const char *key, const void *data, size_t data_size)
adds meta data to request
Definition: evrpc.c:1021
void * evrpc_add_hook(void *vbase, enum EVRPC_HOOK_TYPE hook_type, int(*cb)(void *, struct evhttp_request *, struct evbuffer *, void *), void *cb_arg)
adds a processing hook to either an rpc base or rpc pool
Definition: evrpc.c:119
int evrpc_resume_request(void *vbase, void *ctx, enum EVRPC_HOOK_RESULT res)
resume a paused request
Definition: evrpc.c:770
void evrpc_pool_free(struct evrpc_pool *pool)
frees an rpc connection pool
Definition: evrpc.c:529
Definition: http-internal.h:136
int evrpc_send_request_generic(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 evbuffer *, void *), void(*rpl_clear)(void *), int(*rpl_unmarshal)(void *, struct evbuffer *))
Function for sending a generic RPC request.
Definition: evrpc.c:1071
Definition: rpc_struct.h:59
int evrpc_make_request(struct evrpc_request_wrapper *ctx)
Makes an RPC request based on the provided context.
Definition: evrpc.c:791
Definition: event-internal.h:167
apply the function to an input hook
Definition: rpc.h:453
the request structure that a server receives.
Definition: http_struct.h:57
Definition: evrpc-internal.h:85
EVRPC_HOOK_RESULT
Return value from hook processing functions.
Definition: rpc.h:470