A chain is a set of processes with its own properties like scheduling, notifications, dependencies, outputs, etc.
This is an example of a basic chain with one process:
Runnerty has a default unattended point of view for chains and processes managment. This means that unless you specify a modification propetie for a process or chain it will try to run the next process or the chain until the end. More details below in the action on failed chain section here.
A chain has two identification fields:
id -> Which identifies the chain. With this identifier Runnerty will provide a global value CHAIN_ID that can be used in the whole chain. To learn more about global values have a look here.
name -> It is a description of the chain. Runnerty will also provide the global value CHAIN_NAME
A chain can be fired by using triggers. There is a bunch of different triggers, have a look at them and how to use them here
It is possible to define and overwrite global values at chain level, setting a custom_values attribute:
You can define dependencies with other chains or other chain processes through the depends_chains property. This allows us to execute a chain in these cases:
- When the chain it depends on ends.
The chain will be executed when ´CHAIN-ONE´ finishes
The chain will be executed when
- When the process of the chain it depends on is ends. We will also receive in the input of the chain the values that are indicated in the output_share of the process. This dependency is similar to the one used in iterable chains.
The chain will be executed when
This will cause the processes that depend on the process to wait for the completion of the chain or chains dependent on it. Once the process chain is finished, its flow will continue normally. It is also possible to make the reference process chain fail if the dependent chain fails, by using the fail_on_child_fail property (default is false) in the reference process.
If you need to avoid that two chains can be executed at the same time make use of the queues
With the notifications property, Runnerty can be set up to emit notifications during the chain status flow, fired up by the following callbacks:
In these notifications we could notify anything using notifiers plugins.
The following example shows how to set up notifications for the different states of the chain through Telegram Notifier, publishing messages to a previously defined Telegram's chatroom:
Learn more about notifiers and how to configure them here.
In the processes array property we can defined all the processes that are going to be part of the chain.
Learn more about processes and how to configure them here.
It is possible to define what action (abort or retry) to perform at the chain level in case a process fails. The number of
retries and delay (
retry_delay) settings will be set at the chain level.
Abort the chain if the process fails (this action ends the chain's flow so no other processes will be executed). It is not necessary to indicate, is the default value:
Also you can skip this option (
chain_action_on_fail) so though any process failed, the chain will continue while the dependencies between processes are met (by using
Also, it is possible to indicate in the process that the execution continues even though an error occurs:
This will cause the process error to be reported but the string continue and end without error. Additionally, it could force the chain to end with an error indicating that the process error is taken into account for the final state of the chain:
Delay property understands the following strings:
The space after the number is optional so you can also write
1ms instead of
1 ms. In addition, it also accepts numbers and strings which only includes numbers and we assume that these are always in milliseconds.
From: [Millisecond module](https://github.com/unshiftio/millisecond)
An iterale chain is a chain that is going to be executed for each object in the array previously returned by another process.
For example, if we have a process which returns one objects array we can execute an iterable chain for each object in the array.
In the following example we are going to send an email to every user of the USERS table.
First, we have the chain
get-users-email.json with a process which selects all the users's email:
Then, we assign the returned resultset by the MySQL SELECT query as an object array with the PROCESS_EXEC_DATA_OUTPUT value, as part of the property output_iterable. This way we are announcing this process will return an iterable output.
Now we are going to define the iterable chain "send-mail-to-user"
Here we can see some properties that the chain needs to iterate. First of all we have the dependencies on the depends_chains property.
An iterable chain must depends on the process from the "parent chain" whom it iterates.
With the iterable property we can choose if we want to iterate over in series or parallel:
With the input property we can assign the properties of each object returned by de mother's process array.
Now, we can use these values anywhere in our iterable chain:
In the example
It is possible to define a default value for all the processes in a chain of
chain_action_on_fail, depending on the
defaults_processes property of a chain.
It is also possible to overwrite the default values (
defaults_processes) in each of the processes.
For example, in this case the default value of the
on_start event of
notifications is overwritten in the
PROCESS_SAMPLE process, the rest of the
notifications values will be those defined by default:
These are the metadata that we can indicate from a
|team||Team to which it belongs|
|criticality||Criticality level: low, medium or high|
|contacts||Array of objects with contact data: name, email and phone|
|fail_comments||Comment on action in case the chain fails|
|relaunchable||Indicates if the chain is ready to be relaunched|
|input_keys||Array of strings: indicates which keys are relevant when it comes to distinguishing iterable chains executions. This will be used by the Runnerty IO Platform to make it easier to view chains iterations.|
|keywords||Array of strings: list of keywords|
|max_expected_time||Maximum expected time. It will be used in Runnerty IO Platform to alert on chains that exceed it. The value can be specified in string format ("1000 ms", "1 s", "30 min", "1d" ...)|