UNPKG

pomegranate-task-utilities

Version:

Adds Utility methods to compliment pomegranate-task-runner actions.

251 lines (151 loc) 4.2 kB
# Pomegranate Task Utilities Provides helper functions for working with `Pomegranate-Task-Runner` ### Install ``` shell yarn add pomegranate pomegranate-task-utilities # Or.. npm i -S pomegranate pomegranate-task-utilities ``` ## Configuration This plugin exposes 1 configuration option. `queues` ``` javascript exports.TaskUtilities = function(Env){ return { queues: [ { propName: 'Tasks', queueName: Env.TASK_QUEUE_NAME, type: 'queue', RPC: { enabled: true, defaultTimeout: 1000 }, msgOptions: { persistent: true }, queueOptions: {} } ] } } ``` ## Usage Soon... ## Detailed Documentation <!-- Generated by documentation.js. Update this documentation by updating the source code. --> ### Table of Contents - [TaskValidator][1] - [payload][2] - [notify][3] - [validate][4] - [RpcReply][5] - [TaskBuilder][6] - [task][7] - [notifyTask][8] - [notifyQueue][9] - [payloadProp][10] - [notifyProp][11] - [build][12] ## ./lib/TaskValidator.js **Meta** - **author**: Jim Bulkowski &lt;jim.b@paperelectron.com> - **license**: MIT {@link http&#x3A;//opensource.org/licenses/MIT} ## ./lib/RpcReply.js **Meta** - **author**: Jim Bulkowski &lt;jim.b@paperelectron.com> - **license**: MIT {@link http&#x3A;//opensource.org/licenses/MIT} ## ./lib/TaskBuilder.js **Meta** - **author**: Jim Bulkowski &lt;jim.b@paperelectron.com> - **license**: MIT {@link http&#x3A;//opensource.org/licenses/MIT} ## TaskValidator **Examples** ```javascript let valid = new TaskValidator(Data) .payload(['some', 'paths']) .notify(['other', 'paths']) .validate() ``` ### payload Add paths required **Parameters** - `paths` Returns **[TaskValidator][13]** ### notify **Parameters** - `paths` Returns **[TaskValidator][13]** ### validate Validates the object under test. **Parameters** - `logger` **[Object][14]** Pass in a logger to use when outputting errors. Returns **[boolean][15]** Does the supplied object contain the paths provided. ## RpcReply Formats and sends Remote Procedure Call replies. **Parameters** - `msg` **[Object][14]** And object that will be stringified. - `options` **[Object][14]** RabbitMQ message options. - `options.correlationId` **[string][16]** RMQ correlation ID - `options.replyTo` **[string][16]** RMQ callback queue Returns **[Promise][17]** ## TaskBuilder **Examples** ```javascript let Task = new TaskBuilder() .task('my.awesome.task') .payloadProp('level', 'Awesome') .build() ``` ### task Sets the task name that this builder will target. **Parameters** - `taskName` **[string][16]** the taskname to build Returns **[TaskBuilder][18]** ### notifyTask Sets a taskname to notify **Parameters** - `notifierTaskName` **[string][16]** Returns **[TaskBuilder][18]** ### notifyQueue Sets the queuename that a message should send back to. **Parameters** - `queueName` **[string][16]** \- Returns **[TaskBuilder][18]** ### payloadProp Adds a key-value to the payload of the task. **Parameters** - `prop` **[string][16]** - `val` **any** Returns **[TaskBuilder][18]** ### notifyProp Adds a key-value to the payload of the notify task. **Parameters** - `prop` **[string][16]** - `val` **any** Returns **[TaskBuilder][18]** ### build Builds your Task Object. **Parameters** - `prop` **[string][16]** debug only, returns just this property from .payload Returns **any** [1]: #taskvalidator [2]: #payload [3]: #notify [4]: #validate [5]: #rpcreply [6]: #taskbuilder [7]: #task [8]: #notifytask [9]: #notifyqueue [10]: #payloadprop [11]: #notifyprop [12]: #build [13]: #taskvalidator [14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object [15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise [18]: #taskbuilder