Steps
Steps are the reusable building blocks that make up Processes. A series of Steps can be executed in the context of a Process to achieve a business goal. Unmeshed comes with dozens of Steps out-of-the-box, covering some of the most common automation use-cases. Steps range in complexity from simple http calls to reading/writing database values to executing arbitrary JavaScript code. In some cases, you may want to employ the Standard Worker Step, which allows you to execute your own code on your own server using the Unmeshed client library.
Video Overview: Steps in Unmeshed
Step Definition
A step is defined using the data model Step Definition. Refer to this Step Definition for full details.
Step Context
Every scheduled Step is associated with a StepContext
. This context holds all the relevant information required for
configuring the Step and tracking its execution. Refer to this link for details of the Step Context
Inputs and outputs
Steps receive inputs and produce outputs. Since every Step provides different functionality, each Step defines what input fields are needed for it to operate. You'll find detailed specs for input requirements in the Passing Variables section.
Output of one Step might be used as input for another. The last Step's output is used as the output for the entire Process.
To provide a more concrete example, consider the JAVASCRIPT Step, which is responsible for running arbitrary JavaScript code.
Its input is the actual JavaScript snippet needed to run. After execution, the results are placed in the result
field
within output
. Normally you'd edit the code and evaluate results in the UI, but it can be beneficial to see how
it's represented internally within a StepContext
:
- Input -->
- Output
{
"name": "new_javascript",
"type": "JAVASCRIPT",
"input": {
"script": "() => { console.log('adding 2+2'); return 4; }"
},
}
{
"name": "new_javascript",
"type": "JAVASCRIPT",
"input": {
"script": "() => { console.log('adding 2+2'); return 4; }",
},
"output": {
"result": 4,
"logs": [
{"time": 1729715152787, "log": "adding 2+2!"}
]
},
"status": "COMPLETED",
"lastDuration": 8,
...
}
Workers
Most Steps are executed directly on the Unmeshed platform. It's the easiest way to design and run your Processes without having to worry about performance considerations and/or fault tolerance. However, there may be cases where your code must be executed on your own servers. This is where Standard Workers Steps come in. A Standard Worker is a Step that was especially crafted to receive work from Unmeshed using the Unmeshed client library. Here's what a Java-based worker might look like:
@WorkerMethod("my_worker")
public MyOutput process(MyInput input) {
int random = new Random().nextInt(500, 3000);
return new MyOutput(random);
}
Refer to workers for more details about workers.
Caching support
A step's output can be cached for use in future executions of the same step. This is done using a cache key, which you can configure in the step itself. Refer to the details of the Step Definition to see how to leverage caching with configuration.
Resilience features
Resiliency is controlled with error policies. Refer to the Step Definition on how to configure error policies and refer to the Error Policy for details of the various types of error policies that we support.