Execution Environment

While executing your process definitions, it may be desirable to have some shared state or to send data between nodes via the tokens. Sarasvati supports both these things via the execution environment . Each process has an environment on which attributes/variables can be set. In addition, each token also has its own environment.

When using a memory backed engine, all environment attributes are stored in memory. However, when using a database backed engine, we may wish to persist only certain attributes. Also, storing objects in the database can be complicated, storing arbitrary objects in memory is easier than doing so in the database. By default, attributes are persistent , however, there is a separate set of variables which are transient .

Process Attributes

If you want state that is accessible from anywhere during process execution, then attributes can be set on the process environment. These attributes are visible and mutable by all nodes.

Token Attributes

Each node token also has its own environment. Arc tokens do not have an environment, because they do not execute in the same way that node tokens do, and thus have no need for private state. Node tokens are initialized with the state of their parent tokens .

  • Parent token - Each node tokens has zero to many parents.

    • A node token on a start node has no parents. It will start with an empty environment.

    • A node token on a node with one incoming arc of a given name has a single parent. Its environment will be copied from the parent.

    • A node token on a node using the labe-and join strategy may have multiple parents, one for each arc of the same name. In this case the environments of all the parents must be combined in some way. By default, each environment will be imported into that of the new node. So if more than one parent has an attribute with the same one, the last one imported will overwrite the previous values. This behavior may be overridden, but if this is a concern, then using process level attributes may be advisable.