diff options
author | José Bollo <jose.bollo@iot.bzh> | 2018-07-27 17:38:22 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-08-02 15:49:43 +0200 |
commit | 5ef271effacb83552f9ea56572c751c2f5a556b6 (patch) | |
tree | 3d5f6665bde93633b0eb6c648c9ab46951443526 /docs | |
parent | e39610f8c9b2e6bbb8a460f7d7ccccbc5161b4ed (diff) |
Add ability to provide binding settings
Change-Id: Iab93a26340fa9743a58ca43cd903bbf31c783e5b
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/afb-daemon-options.md | 103 | ||||
-rw-r--r-- | docs/reference-v3/func-api.md | 20 |
2 files changed, 120 insertions, 3 deletions
diff --git a/docs/afb-daemon-options.md b/docs/afb-daemon-options.md index b3a6a185..020991ec 100644 --- a/docs/afb-daemon-options.md +++ b/docs/afb-daemon-options.md @@ -7,6 +7,7 @@ The launch options for binder **afb-daemon** are: -q, --quiet Quiet Mode, repeat to decrease verbosity -l, --log=xxxx Tune log level --foreground Get all in foreground mode + --background Get all in background mode --daemon Get all in background mode -n, --name=xxxx Set the visible name -p, --port=xxxx HTTP listening TCP port [default 1234] @@ -33,15 +34,20 @@ The launch options for binder **afb-daemon** are: -A, --auto-api=xxxx Automatic load of api of the given directory --session-max=xxxx Max count of session simultaneously [default 200] --tracereq=xxxx Log the requests: no, common, extra, all - --traceditf=xxxx Log the daemons: no, common, all - --tracesvc=xxxx Log the services: no, all --traceevt=xxxx Log the events: no, common, extra, all --traceses=xxxx Log the sessions: no, all --traceapi=xxxx Log the apis: no, common, api, event, all + --traceglob=xxxx Log the globals: none, all + --traceditf=xxxx Log the daemons: no, common, all + --tracesvc=xxxx Log the services: no, all -c, --call=xxxx call at start format of val: API/VERB:json-args --no-httpd Forbid HTTP service -e, --exec Execute the remaining arguments -M, --monitoring Enable HTTP monitoring at <ROOT>/monitoring/ + -C, --config=xxxx Load options from the given config file + -Z, --dump-config Dump the config to stdout and exit + -s, --set=xxxx Set parameters ([API]/[KEY]:JSON or {"API":{"KEY":JSON}} + -o, --output=xxxx Redirect stdout and stderr to output file ``` ## help @@ -247,3 +253,96 @@ Set the visible name Automatic activation of api of the given directory when the api is missing. +## config=xxxx + +Load options from the given config file + +This can be used instead of arguments on the command line. + +Example: + + afb-daemon \ + --no-ldpaths \ + --binding /home/15646/bindings/binding45.so \ + --binding /home/15646/bindings/binding3.so \ + --tracereq common \ + --port 5555 \ + --token SPYER \ + --set api45/key:54027a5e3c6cb2ca5ddb97679ce32f185b067b0a557d16a8333758910bc25a72 \ + --exec /home/15646/bin/test654 @p @t + +is equivalent to: + + afb-daemon --config /home/15646/config1 + +when the file **/home/15646/config1** is: + + { + "no-ldpaths": true, + "binding": [ + "\/home\/15646\/bindings\/binding45.so", + "\/home\/15646\/bindings\/binding3.so" + ], + "tracereq": "common", + "port": 5555, + "token": "SPYER", + "set" : { + "api45": { + "key": "54027a5e3c6cb2ca5ddb97679ce32f185b067b0a557d16a8333758910bc25a72" + } + }, + "exec": [ + "\/home\/15646\/bin\/test654", + "@p", + "@t" + ] + } + +The options are the keys of the config object. + +See option --dump-config + +## dump-config + +Output a JSON representation of the configuration resulting from +environment and options. + +## output=xxxx + +Redirect stdout and stderr to output file + +## set=xxxx + +Set values that can be retrieved by bindings. + +The set value can have different formats. + +The most generic format is **{"API1":{"KEY1":VALUE,"KEY2":VALUE2,...},"API2":...}** + +This example set 2 keys for the api *chook*: + + afb-daemon -Z --set '{"chook":{"account":"urn:chook:b2ca5ddb97679","delay":500}}' + { + "set": { + "chook": { + "account": "urn:chook:b2ca5ddb97679", + "delay": 500 + } + } + } + +An other format is: **[API]/[KEY]:VALUE**. +When API is omitted, it take the value "*". +When KEY is ommitted, it take the value of "*". + +The settings for the API \* are globals and apply to all bindings. + +The settings for the KEY \* are mixing the value for the API. + +The following examples are all setting the same values: + + afb-daemon --set '{"chook":{"account":"urn:chook:b2ca5ddb97679","delay":500}}' + afb-daemon --set 'chook/*:{"account":"urn:chook:b2ca5ddb97679","delay":500}' + afb-daemon --set 'chook/:{"account":"urn:chook:b2ca5ddb97679","delay":500}' + afb-daemon --set 'chook/account:"urn:chook:b2ca5ddb97679"' --set chook/delay:500 + diff --git a/docs/reference-v3/func-api.md b/docs/reference-v3/func-api.md index 535bff85..ef3816d0 100644 --- a/docs/reference-v3/func-api.md +++ b/docs/reference-v3/func-api.md @@ -58,7 +58,7 @@ void afb_api_set_userdata( * Check that it requires the API of 'name'. * If 'initialized' is not zero it requests the API to be * initialized, implying its initialization if needed. - * + * * Calling this function is only allowed within init. * * A single request allows to require multiple apis. @@ -255,6 +255,24 @@ int afb_api_rootdir_open_locale( const char *locale); ``` +### afb_api_settings + +```C +/** + * Settings of the api. + * + * Get the settings of the API. The settings are recorded + * as a JSON object. The returned object should not be modified. + * It MUST NOT be released using json_object_put. + * + * @param api the api whose settings are required + * + * @returns The setting object. + */ +struct json_object *afb_api_settings( + struct afb_api_x3 *api); +``` + ## Calls and job functions ### afb_api_call |