Selecting Workflows
Some actions apply to a selection of workflow:
- sending an event to workflows
- pausing or resuming workflows
- terminating workflows
Currently, there are 3 ways to select workflows:
Type | selector value |
---|---|
by id | this.select.workflow().withId("<id>") |
by name | this.select.workflow("<name>") |
by name and tag | this.select.workflow("<name>").withTag("<tag>") |
This selector
value should be used in requests below. For example:
const selector = this.select.workflow("<name>").withTag("<tag>");
For example:
module.exports.handle = function* (...) {
...
// select a workflow
const selector = this.select.workflow("<name>").withTag("<tag>");
// send an event to it
selector.send("<event name>", ...<event data>);
// pause it
yield selector.pause();
// resume it
yield selector.resume();
// terminate it
yield selector.terminate();
...
};
The ability for workflows to dispatch new workflows and to be able to communicate between them through events is a very powerful pattern, similar to the actor model.