This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Action Modules
Anthony Clavio edited this page Nov 24, 2020
·
5 revisions
Action modules are the primary unit of work for State Conductor state machines. Action modules are referenced by Task states' "Resource" field. The State Conductor ships with action modules for some common activities. Custom action modules can be written in server-side javascript and referenced in your State Machine definition files.
Custom action modules must export a function named performAction
with the following signature:
'use strict';
function performAction(uri, options = {}, context = {}) {
// TODO implementation
return context;
}
exports.performAction = performAction;
- uri - (String) the URI of the in-process document
- options - (Object) a JSON object containing values from the "Parameters" field of the current Task state
- context - (Object) the JSON context object of the current execution. Used to pass data between state-machine states.
- return - (Any) the value returned by the
performAction
function will be saved as the current Execution's context and passed to any subsequent Task states. It is recommended to update and return the passed in context object.
Custom action modules should be deployed alongside any application code to your application's Modules database. They are then referenced by URI relative to the root of that Modules database.
example:
{
"Type": "Task",
"Comment": "runs custom action module",
"Resource": "/my-application/actions/do-the-thing.sjs",
"Parameters": {
"foo": "bar"
}
}