UNPKG

usher

Version:

Simple DSL for composing decision workflows for AWS Simple Workflow

155 lines (113 loc) 4.26 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: usher.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: usher.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>/*! * Usher * Copyright(c) 2014 meltmedia &lt;mike@meltmedia.com> */ 'use strict'; var util = require('util'), events = require('events'), _ = require('lodash'), Fragment = require('./decider/fragment'), WorkflowPoller = require('./decider/poller'), ActivityPoller = require('./activity/poller'); /** * Manages workflows * @constructor */ function Usher() { if (!(this instanceof Usher)) { return new Usher(); } events.EventEmitter.call(this); this.workflows = {}; this.fragments = {}; this.pollers = {}; } // Make Usher an EventEmitter util.inherits(Usher, events.EventEmitter); /** * Create or retrieve a workflow * @param {string} name - The name of the workflow. * @param {string} domain - The AWS SWF domain name to execute this workflow in. * @param {object} [options] - Additional SWF options used when creating and executing this workflow * (taskList, tagList, childPolicy, executionStartToCloseTimeout, taskStartToCloseTimeout) * @returns {DecisionPoller} - A workflow poller where specific versions of a workflow can be defined */ Usher.prototype.workflow = function workflow(name, domain, options) { var id = name + '-' + domain, result = this.workflows[id]; // If we are defining a new workflow if (_.isUndefined(result)) { // New poller result = new WorkflowPoller(name, domain, options); this.workflows[id] = result; } return result; }; /** * Create or retrieve a workflow fragment * @param {string} name - The name of the fragment. * @returns {Fragment} - A workflow fragment instance */ Usher.prototype.fragment = function fragment(name) { var result = this.fragments[name]; // If we are defining a new workflow if (_.isUndefined(result)) { // New workflow result = new Fragment(name); this.fragments[name] = result; } return result; }; /** * Create or retrieve a activity poller * @param {string} name - The name of the poller. * @param {string} domain - The AWS SWF domain name to execute the pollers activities in. * @param {object} [options] - Additional SWF options used when polling for activities * (taskList=&lt;name>-tasklist) * @returns {ActivityPoller} - A activity poller instance where specific activities can be defined */ Usher.prototype.activities = function activities(name, domain, options) { var id = name + '-' + domain, result = this.pollers[id]; // If we are defining a new workflow if (_.isUndefined(result)) { // New poller result = new ActivityPoller(name, domain, options); this.pollers[id] = result; } return result; }; module.exports = new Usher(); </code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Accumulator.html">Accumulator</a></li><li><a href="ActivityPoller.html">ActivityPoller</a></li><li><a href="ActivityTask.html">ActivityTask</a></li><li><a href="DecisionPoller.html">DecisionPoller</a></li><li><a href="Fragment.html">Fragment</a></li><li><a href="Loop.html">Loop</a></li><li><a href="Usher.html">Usher</a></li><li><a href="WhileLoop.html">WhileLoop</a></li><li><a href="WorkflowVersion.html">WorkflowVersion</a></li></ul> </nav> <br clear="both"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Mon Sep 12 2016 14:59:00 GMT-0700 (MST) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>