diff --git a/Documentation/Books/Users/Foxx/FoxxQueues.mdpp b/Documentation/Books/Users/Foxx/FoxxQueues.mdpp index 9c37ff8245..8a981b7488 100644 --- a/Documentation/Books/Users/Foxx/FoxxQueues.mdpp +++ b/Documentation/Books/Users/Foxx/FoxxQueues.mdpp @@ -117,6 +117,7 @@ If *opts* is a function, it will be treated as the *execute* function. * *execute*: a function to pass the job data to when a job is executed. * *maxFailures* (optional): the number of times a job will be re-tried before it is marked as *"failed"*. A negative value or *Infinity* means that the job will be re-tried on failure indefinitely. Default: *0*. * *schema* (optional): a [Joi](https://github.com/hapijs/joi) schema to validate a job's data against before accepting it. + * *preprocess* (optional): a function to pre-process a job's (validated) data before serializing it in the queue. * *backOff* (optional): either a function that takes the number of times the job has failed before as input and returns the number of milliseconds to wait before trying the job again, or the delay to be used to calculate an [exponential back-off](https://en.wikipedia.org/wiki/Exponential_backoff), or *0* for no delay. Default: *1000*. *Examples* diff --git a/js/server/modules/org/arangodb/foxx/queues.js b/js/server/modules/org/arangodb/foxx/queues.js index 9647979b96..adde2dd973 100644 --- a/js/server/modules/org/arangodb/foxx/queues.js +++ b/js/server/modules/org/arangodb/foxx/queues.js @@ -224,6 +224,9 @@ _.extend(Queue.prototype, { } data = result.value; } + if (type.preprocess) { + data = type.preprocess(data); + } } else if (opts.allowUnknown) { console.warn('Unknown job type: ' + name); } else {