ldn-inbox-server
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -43,2 +43,6 @@ { | ||
[ | ||
{ | ||
"id": "@handler/notification_handler/on_error.js", | ||
"handler": "@handler/notification_handler/nothing.js" | ||
}, | ||
{ | ||
@@ -45,0 +49,0 @@ "id": "@handler/notification_handler/jsonpath_filter.js", |
@@ -12,4 +12,2 @@ const fs = require('fs'); | ||
async function handle({path,options,config}) { | ||
logger.info(`parsing notification ${path}`); | ||
try { | ||
@@ -16,0 +14,0 @@ const json = parseAsJSON(path); |
@@ -10,4 +10,2 @@ const fs = require('fs'); | ||
async function handle({path,options,config}) { | ||
logger.info(`parsing notification ${path}`); | ||
const eventlog = options['eventlog']; | ||
@@ -14,0 +12,0 @@ |
@@ -10,4 +10,2 @@ const fs = require('fs'); | ||
async function handle({path,options,config}) { | ||
logger.info(`parsing notification ${path}`); | ||
if (! config) { | ||
@@ -14,0 +12,0 @@ logger.error('no configuration found for eventlog_notification_handler'); |
@@ -10,4 +10,2 @@ const jp = require('jsonpath'); | ||
async function handle({path,options,config}) { | ||
logger.info(`parsing notification ${path}`); | ||
if (! config) { | ||
@@ -14,0 +12,0 @@ logger.error('no configuration found for eventlog_notification_handler'); |
@@ -68,2 +68,25 @@ const { dynamic_handler , parseConfig , parseAsJSON } = require('../../lib/util.js'); | ||
thisWorkflow = false; | ||
if (options['fallback']) { | ||
logger.debug(`loading fallback ${options['fallback']}`); | ||
const fallback = dynamic_handler(options['fallback'],null); | ||
if (!fallback) { | ||
throw new Error(`failed to load ${options['fallback']}`); | ||
} | ||
logger.info(`workflow[${i}] : starting ${options['fallback']}`); | ||
const fallback_result = await fallback({path,options,config,notification}); | ||
if (fallback_result['success']) { | ||
logger.info(`workflow[${i}] : finished ${options['fallback']}`); | ||
} | ||
else { | ||
logger.error(`workflow[${i}] : failed ${options['fallback']}`); | ||
} | ||
} | ||
else { | ||
logger.debug(`no fallBack defined`); | ||
} | ||
break; | ||
@@ -85,2 +108,5 @@ } | ||
} | ||
// Each workflow needs to install its own fallBack | ||
delete options['fallback']; | ||
} | ||
@@ -87,0 +113,0 @@ |
@@ -11,4 +11,2 @@ const fs = require('fs'); | ||
async function handle({path,options,config}) { | ||
logger.info(`parsing notification ${path}`); | ||
if (! config) { | ||
@@ -15,0 +13,0 @@ logger.error('no configuration found for offer_memento'); |
@@ -9,4 +9,2 @@ const { parseAsJSON } = require('../../lib/util.js'); | ||
async function handle({path,options,config}) { | ||
logger.info(`parsing notification ${path}`); | ||
if (! config) { | ||
@@ -13,0 +11,0 @@ logger.error('no configuration found for eventlog_notification_handler'); |
@@ -9,4 +9,2 @@ const { ldPropertyAsId , parseArtifact, parseAsJSON } = require('../../lib/util.js'); | ||
async function handle({path,options,config}) { | ||
logger.info(`parsing notification ${path}`); | ||
try { | ||
@@ -13,0 +11,0 @@ const json = parseAsJSON(path); |
@@ -9,4 +9,2 @@ const { ldPropertyAsId , parseEventLog, parseAsJSON } = require('../../lib/util.js'); | ||
async function handle({path,options,config}) { | ||
logger.info(`parsing notification ${path}`); | ||
try { | ||
@@ -13,0 +11,0 @@ const json = parseAsJSON(path); |
{ | ||
"name": "ldn-inbox-server", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "A demonstration Event Notifications Inbox server", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -179,4 +179,14 @@ # ldn-inbox-server | ||
A `handler/multi_notification_handler.js` is available to start multiple handler for each notification messages. The handlers to start are specified in a configuration file that can be passed via the `config` parameter of an `handle_inbox`. In the commmand line tool `bin/ldn-inbox-server` the default location of such config file is `config/inbox_config.json` when processing an `@inbox`, and `config/outbox_config.json` when processing an `@outbox`. | ||
A `handler/multi_notification_handler.js` is available to start multiple handler for each notification messages. The handlers to start are specified in a configuration file that can be passed via the `config` parameter of an `handle_inbox`. For the commmand line tool `bin/ldn-inbox-server` the default location of such config file is `config/inbox_config.json` when processing an `@inbox`, and `config/outbox_config.json` when processing an `@outbox`. | ||
The multi handler requires a configuration file with properties `notification_handler.multi.handlers` which is an array of array. Each outer array defines a list of handlers that should be executed sequentially on a notification until one handler returns a `false` response or the last handler returns a `true` response. | ||
Each handler is defined by a hash containing as `id` property the path to the handler and optionally other property keys that will be passed to the handlers in the `config` section. | ||
Optionally when a `fallback` handler is defined as option it will be attempted when a handler in a sequence returns a `false` response. | ||
### On Error handler | ||
A handler that sets the `fallback` for a workflow sequence. | ||
### Offer memento handler | ||
@@ -183,0 +193,0 @@ |
69861
34
1566
237