Class: Fragment

Fragment

new Fragment(name, domain, tasklist)

Represents a single, named workflow, where all activities and decisions are defined.
Parameters:
Name Type Argument Default Description
name string The name of the workflow.
domain string The AWS SWF domain name to execute this workflow in.
tasklist string <optional>
<name>-tasklist The name of the tasklist to listen for tasks on.
Source:

Methods

accumulator(name, deps, fragment, doneFn, options) → {Fragment}

Add a accumulator execution to the workflow The accumulator executes a fragment until the `doneFn` returns a truthy value, taking the results of each iteration and making them available to any dependents
Parameters:
Name Type Argument Description
name string The unique name of the accumulator fragment.
deps Array <optional>
The names of the dependencies that must be met before this activity can execute.
fragment Fragment The workflow fragment to iterate over. Generated by `usher.fragment()`
doneFn function Indicates when the accumulator is complete by returning a truthy value.
options Object <optional>
Custom options for this activity.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

activity(name, deps, options) → {Fragment}

Add an activity to the workflow
Parameters:
Name Type Argument Description
name string The unique name of the activity.
deps Array <optional>
The names of the dependencies that must be met before this activity can execute.
options Object <optional>
Custom options for this activity.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

activityDefaults(options) → {Fragment}

Set global activity options for the entire workflow
Parameters:
Name Type Description
options Object Custom options to use for all defined activities.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

child(name, deps, workflowName, workflowVersion, options) → {Fragment}

Add an child workflow execution to the workflow
Parameters:
Name Type Argument Description
name string The unique name of the child workflow.
deps Array <optional>
The names of the dependencies that must be met before this activity can execute.
workflowName string The name of the workflow to execute.
workflowVersion string The version of the workflow to execute.
options Object <optional>
Custom options for this activity.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

decision(name, deps, decisionFn) → {Fragment}

Add a decision to the workflow
Parameters:
Name Type Argument Description
name string The unique name of the decision.
deps Array <optional>
The names of the dependencies that must be met before this decision can execute.
decisionFn Fragment~decisionLogic The logic for this decision.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

loop(name, deps, fragment, loopFn, options) → {Fragment}

Add a looping workflow execution to the workflow The loop executes in batches to help alleviate rate limit exceptions. The number of items to proccess per batch and the delay between batches are both configurable.
Parameters:
Name Type Argument Description
name string The unique name of the loop fragment.
deps Array <optional>
The names of the dependencies that must be met before this activity can execute.
fragment Fragment The workflow fragment to loop over. Generated by `usher.fragment()`
loopFn function A function given the taks's input that returns an array. For every item in the Array an execution of the `fragment` workflow will execute.
options Object <optional>
Custom options for this activity. [itemsPerBatch, batchDelay]
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

result(name, deps, transformFn) → {Fragment}

Add a result transformation to the workflow. This sets the fragments results based on the `transformFn`
Parameters:
Name Type Argument Description
name string The unique name of the result task.
deps Array <optional>
The names of the dependencies that must be met before this decision can execute.
transformFn Fragment~transformationLogic <optional>
The funtion that will perform the transformation.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

sequencedTasks() → {Array}

Get the defined tasks for the fragment in execution order
Source:
Returns:
An array of defined tasks
Type
Array

tasks() → {Array}

Get the defined tasks for the fragment
Source:
Returns:
An array of defined tasks
Type
Array

terminate(name, deps) → {Fragment}

Add a termination point to the workflow
Parameters:
Name Type Argument Description
name string The unique name that represents this termination point.
deps Array <optional>
The names of the dependencies that must be met before the workflow can terminate.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

transform(name, deps, transformFn) → {Fragment}

Add a transformation to the workflow. Transformations are good for manipulating the results of prior activities into new representations for future dependents.
Parameters:
Name Type Argument Description
name string The unique name of the transformation.
deps Array <optional>
The names of the dependencies that must be met before this decision can execute.
transformFn Fragment~transformationLogic <optional>
The funtion that will perform the transformation.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

variable(name, deps, valueFn) → {Fragment}

Set an variable accessable to all future scheduled activities
Parameters:
Name Type Argument Description
name string The unique name of the variable.
deps Array <optional>
The names of the dependencies that must be met before this variable can be set.
valueFn Fragment~variableValueFunction <optional>
The funtion that will calculate the variable name.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

whileLoop(name, deps, fragment, doneFn, options) → {Fragment}

Add a while loop workflow execution to the workflow The loop executes until the `doneFn` returns a truthy value
Parameters:
Name Type Argument Description
name string The unique name of the while loop fragment.
deps Array <optional>
The names of the dependencies that must be met before this activity can execute.
fragment Fragment The workflow fragment to loop over. Generated by `usher.fragment()`
doneFn function Indicates when the loop is complete by returning a truthy value.
options Object <optional>
Custom options for this activity.
Source:
Returns:
This workflow so you can chain commands.
Type
Fragment

Type Definitions

decisionLogic(input) → {Boolean}

The decision logic to execute when evaluating the given named decision
Parameters:
Name Type Description
input Object The results of all dependencies for this decision
Source:
Returns:
Should dependents of this decision execute
Type
Boolean

transformationLogic(input) → {*}

The tranformation to execute
Parameters:
Name Type Description
input Object The results of all dependencies for this transformation
Source:
Returns:
The transformed input
Type
*

variableValueFunction(input) → {*}

A function to determine the value of the variable
Parameters:
Name Type Description
input Object The results of all dependencies for this variable
Source:
Returns:
The variable value
Type
*