- integration of the security requirements within the bindings
- simplification of the API (after developer feedbacks)
- integration of the security requirements within the bindings
- simplification of the API (after developer feedbacks)
The ***binder*** can run ***bindings*** v1 and/or v2 in any combination.
Thus moving from v1 to v2 is not enforced. There is no real need.
The ***binder*** can run ***bindings*** v1 and/or v2 in any combination.
Thus moving from v1 to v2 is not enforced. There is no real need.
More, it is possible to write a dual ***binding***: a ***binding*** that
implements the version 1 AND the version 2.
More, it is possible to write a dual ***binding***: a ***binding*** that
implements the version 1 AND the version 2.
- existing ***bindings*** SHOULD migrate to the version 2
This guide covers the migration of bindings from version 1 to version 2.
- existing ***bindings*** SHOULD migrate to the version 2
This guide covers the migration of bindings from version 1 to version 2.
It simplifies the job, that's all and that is the reason of the change.
An other important difference is between the version 1 and the version 2 is
It simplifies the job, that's all and that is the reason of the change.
An other important difference is between the version 1 and the version 2 is
**OpenAPI v3** description of the **API**. For this reason, to avoid
duplication of descriptions, only one description is expected: the **OpenAPI** one.
**OpenAPI v3** description of the **API**. For this reason, to avoid
duplication of descriptions, only one description is expected: the **OpenAPI** one.
5. Consider where to emit logs for requests
6. Take care of store/unstore changes
7. Consider use of synchronous (sub)call requests
5. Consider where to emit logs for requests
6. Take care of store/unstore changes
7. Consider use of synchronous (sub)call requests
void (*callback)(struct afb_req req); /* callback function implementing the verb */
const char *info; /* textual description of the verb */
};
void (*callback)(struct afb_req req); /* callback function implementing the verb */
const char *info; /* textual description of the verb */
};
{
const char *verb; /* name of the verb */
void (*callback)(struct afb_req req); /* callback function implementing the verb */
{
const char *verb; /* name of the verb */
void (*callback)(struct afb_req req); /* callback function implementing the verb */
- const struct afb_auth *auth; /* required authorisation */
- uint32_t session; /* authorisation and session requirements of the verb */
+ const struct afb_auth *auth; /* required authorization */
+ uint32_t session; /* authorization and session requirements of the verb */
- set the field **noconcurrency** to the right value:
* to 1 if you want to avoid concurrent calls to verbs.
* to 0 if you allow concurrent calls to verbs.
- set the field **noconcurrency** to the right value:
* to 1 if you want to avoid concurrent calls to verbs.
* to 0 if you allow concurrent calls to verbs.
The function **afbBindingV1ServiceInit** is replaced by the field **init**
of the structure **afbBindingV2**. The init function should return 0 in case
of success or a negative error code in case of problem. It is called during
The function **afbBindingV1ServiceInit** is replaced by the field **init**
of the structure **afbBindingV2**. The init function should return 0 in case
of success or a negative error code in case of problem. It is called during
The function **afbBindingV1ServiceEvent**is replaced by the field **onevent**
of the structure **afbBindingV2**.
The function **afbBindingV1ServiceEvent**is replaced by the field **onevent**
of the structure **afbBindingV2**.
So the variable that ***bindings*** version used to store the ***binder*** interface
and the service interface are no more needed and can be removed.
So the variable that ***bindings*** version used to store the ***binder*** interface
and the service interface are no more needed and can be removed.
Also, to avoid possible conflicts, we introduced prefixed logging functions:
the macros **ERROR**, **WARNING**, **NOTICE**, **INFO**, **DEBUG** have now
a prefixed version: **AFB\_ERROR**, **AFB\_WARNING**, **AFB\_NOTICE**,
Also, to avoid possible conflicts, we introduced prefixed logging functions:
the macros **ERROR**, **WARNING**, **NOTICE**, **INFO**, **DEBUG** have now
a prefixed version: **AFB\_ERROR**, **AFB\_WARNING**, **AFB\_NOTICE**,
**NOTICE**, **INFO**, **DEBUG** and just define **AFB_BINDING_PRAGMA_NO_VERBOSE_UNPREFIX**
before to include **afb/afb-binding.h**.
**NOTICE**, **INFO**, **DEBUG** and just define **AFB_BINDING_PRAGMA_NO_VERBOSE_UNPREFIX**
before to include **afb/afb-binding.h**.
The ***bindings*** v2 now allows to emit log messages associated to ***requests***.
This feature is valuable when debugging because it allows to return
The ***bindings*** v2 now allows to emit log messages associated to ***requests***.
This feature is valuable when debugging because it allows to return
The defined macros for logging to requests are: **AFB_REQ_ERROR**,
**AFB_REQ_WARNING**, **AFB_REQ_NOTICE**, **AFB_REQ_INFO**, **AFB_REQ_DEBUG**.
The defined macros for logging to requests are: **AFB_REQ_ERROR**,
**AFB_REQ_WARNING**, **AFB_REQ_NOTICE**, **AFB_REQ_INFO**, **AFB_REQ_DEBUG**.
their clients (subcalls). With ***bindings*** version 2 comes
also synchronous requests for both cases.
their clients (subcalls). With ***bindings*** version 2 comes
also synchronous requests for both cases.
to replace the asynchronous requests (with asynchronous call back)
by synchronous ones.
See functions ***afb_service_call_sync*** and ***afb_req_subcall_sync***.
to replace the asynchronous requests (with asynchronous call back)
by synchronous ones.
See functions ***afb_service_call_sync*** and ***afb_req_subcall_sync***.
-const struct afb_binding_interface *interface;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
struct event
@@ -79,7 +80,7 @@ static int event_add(const char *tag, const char *name)
strcpy(e->tag, tag);
-const struct afb_binding_interface *interface;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
struct event
@@ -79,7 +80,7 @@ static int event_add(const char *tag, const char *name)
strcpy(e->tag, tag);
/* make the event */
- e->event = afb_daemon_make_event(interface->daemon, name);
+ e->event = afb_daemon_make_event(name);
if (!e->event.closure) { free(e); return -1; }
/* make the event */
- e->event = afb_daemon_make_event(interface->daemon, name);
+ e->event = afb_daemon_make_event(name);
if (!e->event.closure) { free(e); return -1; }
/* link */
@@ -140,7 +141,7 @@ static void pingBug (struct afb_req request)
static void pingEvent(struct afb_req request)
/* link */
@@ -140,7 +141,7 @@ static void pingBug (struct afb_req request)
static void pingEvent(struct afb_req request)
+ afb_daemon_broadcast_event("event", json_object_get(query));
ping(request, json_object_get(query), "event");
}
+ afb_daemon_broadcast_event("event", json_object_get(query));
ping(request, json_object_get(query), "event");
}
+ { "exit", exitnow , NULL, AFB_SESSION_NONE },
+ { NULL}
};
+ { "exit", exitnow , NULL, AFB_SESSION_NONE },
+ { NULL}
};
-static const struct afb_binding plugin_desc = {
- .type = AFB_BINDING_VERSION_1,
- .v1 = {
-static const struct afb_binding plugin_desc = {
- .type = AFB_BINDING_VERSION_1,
- .v1 = {