-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
55 lines (55 loc) · 9.38 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
"name": "orchestrator",
"description": "A module for sequencing and executing tasks and dependencies in maximum concurrency",
"version": "0.3.7",
"homepage": "https://github.com/robrich/orchestrator",
"repository": {
"type": "git",
"url": "git://github.com/robrich/orchestrator.git"
},
"author": {
"name": "Rob Richardson",
"url": "http://robrich.org/"
},
"main": "./index.js",
"keywords": [
"async",
"task",
"parallel",
"compose"
],
"dependencies": {
"end-of-stream": "~0.1.5",
"sequencify": "~0.0.7",
"stream-consume": "~0.1.0"
},
"devDependencies": {
"event-stream": "~3.1.5",
"gulp-jshint": "~1.6.3",
"map-stream": "~0.1.0",
"merge-stream": "~0.1.2",
"mocha": "~1.17.0",
"q": "~1.0.0",
"should": "~3.0.1",
"vinyl-fs": "~0.3.4"
},
"scripts": {
"test": "mocha"
},
"engines": {
"node": ">= 0.8"
},
"licenses": [
{
"type": "MIT",
"url": "http://github.com/robrich/orchestrator/raw/master/LICENSE"
}
],
"readme": "[![Build Status](https://secure.travis-ci.org/orchestrator/orchestrator.svg?branch=master)](https://travis-ci.org/orchestrator/orchestrator)\n[![Dependency Status](https://david-dm.org/orchestrator/orchestrator.svg)](https://david-dm.org/orchestrator/orchestrator)\n\nOrchestrator\n============\n\nA module for sequencing and executing tasks and dependencies in maximum concurrency\n\nUsage\n-----\n\n### 1. Get a reference:\n\n```javascript\nvar Orchestrator = require('orchestrator');\nvar orchestrator = new Orchestrator();\n```\n\n### 2. Load it up with stuff to do:\n\n```javascript\norchestrator.add('thing1', function(){\n // do stuff\n});\norchestrator.add('thing2', function(){\n // do stuff\n});\n```\n\n### 3. Run the tasks:\n\n```javascript\norchestrator.start('thing1', 'thing2', function (err) {\n // all done\n});\n```\n\nAPI\n---\n\n### orchestrator.add(name[, deps][, function]);\n\nDefine a task\n\n```javascript\norchestrator.add('thing1', function(){\n // do stuff\n});\n```\n\n#### name\nType: `String`\n\nThe name of the task.\n\n#### deps\nType: `Array`\n\nAn array of task names to be executed and completed before your task will run.\n\n```javascript\norchestrator.add('mytask', ['array', 'of', 'task', 'names'], function() {\n // Do stuff\n});\n```\n\n**Note:** Are your tasks running before the dependencies are complete? Make sure your dependency tasks\nare correctly using the async run hints: take in a callback or return a promise or event stream.\n\n#### fn\nType: `function`\n\nThe function that performs the task's operations. For asynchronous tasks, you need to provide a hint when the task is complete:\n\n- Take in a callback\n- Return a stream or a promise\n\n#### examples:\n\n**Accept a callback:**\n\n```javascript\norchestrator.add('thing2', function(callback){\n // do stuff\n callback(err);\n});\n```\n\n**Return a promise:**\n\n```javascript\nvar Q = require('q');\n\norchestrator.add('thing3', function(){\n var deferred = Q.defer();\n\n // do async stuff\n setTimeout(function () {\n deferred.resolve();\n }, 1);\n\n return deferred.promise;\n});\n```\n\n**Return a stream:** (task is marked complete when stream ends)\n\n```javascript\nvar map = require('map-stream');\n\norchestrator.add('thing4', function(){\n var stream = map(function (args, cb) {\n cb(null, args);\n });\n // do stream stuff\n return stream;\n});\n```\n\n**Note:** By default, tasks run with maximum concurrency -- e.g. it launches all the tasks at once and waits for nothing.\nIf you want to create a series where tasks run in a particular order, you need to do two things:\n\n- give it a hint to tell it when the task is done,\n- and give it a hint that a task depends on completion of another.\n\nFor these examples, let's presume you have two tasks, \"one\" and \"two\" that you specifically want to run in this order:\n\n1. In task \"one\" you add a hint to tell it when the task is done. Either take in a callback and call it when you're\ndone or return a promise or stream that the engine should wait to resolve or end respectively.\n\n2. In task \"two\" you add a hint telling the engine that it depends on completion of the first task.\n\nSo this example would look like this:\n\n```javascript\nvar Orchestrator = require('orchestrator');\nvar orchestrator = new Orchestrator();\n\n// takes in a callback so the engine knows when it'll be done\norchestrator.add('one', function (cb) {\n // do stuff -- async or otherwise\n cb(err); // if err is not null or undefined, the orchestration will stop, and note that it failed\n});\n\n// identifies a dependent task must be complete before this one begins\norchestrator.add('two', ['one'], function () {\n // task 'one' is done now\n});\n\norchestrator.start('one', 'two');\n```\n\n### orchestrator.hasTask(name);\n\nHave you defined a task with this name?\n\n#### name\nType: `String`\n\nThe task name to query\n\n### orchestrator.start(tasks...[, cb]);\n\nStart running the tasks\n\n#### tasks\nType: `String` or `Array` of `String`s\n\nTasks to be executed. You may pass any number of tasks as individual arguments.\n\n#### cb\nType: `function`: `function (err) {`\n\nCallback to call after run completed.\n\nPasses single argument: `err`: did the orchestration succeed?\n\n**Note:** Tasks run concurrently and therefore may not complete in order.\n**Note:** Orchestrator uses `sequencify` to resolve dependencies before running, and therefore may not start in order.\nListen to orchestration events to watch task running.\n\n```javascript\norchestrator.start('thing1', 'thing2', 'thing3', 'thing4', function (err) {\n // all done\n});\n```\n```javascript\norchestrator.start(['thing1','thing2'], ['thing3','thing4']);\n```\n\n**FRAGILE:** Orchestrator catches exceptions on sync runs to pass to your callback\nbut doesn't hook to process.uncaughtException so it can't pass those exceptions\nto your callback\n\n**FRAGILE:** Orchestrator will ensure each task and each dependency is run once during an orchestration run\neven if you specify it to run more than once. (e.g. `orchestrator.start('thing1', 'thing1')`\nwill only run 'thing1' once.) If you need it to run a task multiple times, wait for\nthe orchestration to end (start's callback) then call start again.\n(e.g. `orchestrator.start('thing1', function () {orchestrator.start('thing1');})`.)\nAlternatively create a second orchestrator instance.\n\n### orchestrator.stop()\n\nStop an orchestration run currently in process\n\n**Note:** It will call the `start()` callback with an `err` noting the orchestration was aborted\n\n### orchestrator.on(event, cb);\n\nListen to orchestrator internals\n\n#### event\nType: `String`\n\nEvent name to listen to:\n- start: from start() method, shows you the task sequence\n- stop: from stop() method, the queue finished successfully\n- err: from stop() method, the queue was aborted due to a task error\n- task_start: from _runTask() method, task was started\n- task_stop: from _runTask() method, task completed successfully\n- task_err: from _runTask() method, task errored\n- task_not_found: from start() method, you're trying to start a task that doesn't exist\n- task_recursion: from start() method, there are recursive dependencies in your task list\n\n#### cb\nType: `function`: `function (e) {`\n\nPasses single argument: `e`: event details\n\n```javascript\norchestrator.on('task_start', function (e) {\n // e.message is the log message\n // e.task is the task name if the message applies to a task else `undefined`\n // e.err is the error if event is 'err' else `undefined`\n});\n// for task_end and task_err:\norchestrator.on('task_stop', function (e) {\n // e is the same object from task_start\n // e.message is updated to show how the task ended\n // e.duration is the task run duration (in seconds)\n});\n```\n\n**Note:** fires either *stop or *err but not both.\n\n### orchestrator.onAll(cb);\n\nListen to all orchestrator events from one callback\n\n#### cb\nType: `function`: `function (e) {`\n\nPasses single argument: `e`: event details\n\n```javascript\norchestrator.onAll(function (e) {\n // e is the original event args\n // e.src is event name\n});\n```\n\nLICENSE\n-------\n\n(MIT License)\n\nCopyright (c) 2013 [Richardson & Sons, LLC](http://richardsonandsons.com/)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/robrich/orchestrator/issues"
},
"_id": "orchestrator@0.3.7",
"_from": "orchestrator@^0.3.0"
}