aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-hook.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-08-02 19:14:09 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-08-03 11:47:27 +0200
commitbdff72f45e1d02f596595f6229d5bccf7c0827c2 (patch)
tree9a4eb13b2d784df41e7e46cbcc2fab6fab9977c7 /src/afb-hook.c
parentd0c20134a2c9ecb53045b63cb1e0d6e2aa2b26d2 (diff)
subcall_req: introduce afb_req_subcall_req
The function 'afb_req_subcall_req' can be used to make asynchronous subcalls. It improves the function 'afb_req_subcall' by automatically keeping the request opened for the callback and by passing it, the request, as an extra argument of the callback. Change-Id: I2dc79c01fc25c7a65b9c8cc9e001a5b85fba99df Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-hook.c')
-rw-r--r--src/afb-hook.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/afb-hook.c b/src/afb-hook.c
index 2f101bf5..05b04aec 100644
--- a/src/afb-hook.c
+++ b/src/afb-hook.c
@@ -281,6 +281,16 @@ static void hook_xreq_unstore_default_cb(void * closure, const struct afb_xreq *
_hook_xreq_(xreq, "unstore()");
}
+static void hook_xreq_subcall_req_default_cb(void * closure, const struct afb_xreq *xreq, const char *api, const char *verb, struct json_object *args)
+{
+ _hook_xreq_(xreq, "subcall_req(%s/%s, %s) ...", api, verb, json_object_to_json_string(args));
+}
+
+static void hook_xreq_subcall_req_result_default_cb(void * closure, const struct afb_xreq *xreq, int status, struct json_object *result)
+{
+ _hook_xreq_(xreq, " ...subcall_req... -> %d: %s", status, json_object_to_json_string(result));
+}
+
static struct afb_hook_xreq_itf hook_xreq_default_itf = {
.hook_xreq_begin = hook_xreq_begin_default_cb,
.hook_xreq_end = hook_xreq_end_default_cb,
@@ -302,7 +312,9 @@ static struct afb_hook_xreq_itf hook_xreq_default_itf = {
.hook_xreq_subcallsync_result = hook_xreq_subcallsync_result_default_cb,
.hook_xreq_vverbose = hook_xreq_vverbose_default_cb,
.hook_xreq_store = hook_xreq_store_default_cb,
- .hook_xreq_unstore = hook_xreq_unstore_default_cb
+ .hook_xreq_unstore = hook_xreq_unstore_default_cb,
+ .hook_xreq_subcall_req = hook_xreq_subcall_req_default_cb,
+ .hook_xreq_subcall_req_result = hook_xreq_subcall_req_result_default_cb
};
/******************************************************************************
@@ -438,6 +450,16 @@ void afb_hook_xreq_unstore(const struct afb_xreq *xreq)
_HOOK_XREQ_(unstore, xreq);
}
+void afb_hook_xreq_subcall_req(const struct afb_xreq *xreq, const char *api, const char *verb, struct json_object *args)
+{
+ _HOOK_XREQ_(subcall_req, xreq, api, verb, args);
+}
+
+void afb_hook_xreq_subcall_req_result(const struct afb_xreq *xreq, int status, struct json_object *result)
+{
+ _HOOK_XREQ_(subcall_req_result, xreq, status, result);
+}
+
/******************************************************************************
* section: hooking xreqs
*****************************************************************************/