pub struct Node { /* private fields */ }
Expand description
Describes a node in the saga DAG
There are three kinds of nodes you can add to a graph:
- an action (see
Node::action
), which executes a particularAction
with an associated undo action - a constant (see
Node::constant
), which is like an action that outputs a value that’s known when the DAG is constructed - a subsaga (see
Node::subsaga
), which executes another DAG in the context of this saga
Each of these node types has a node_name
and produces an output. Other
nodes that depend on this node (directly or indirectly) can access the
output by looking it up by the node name using
crate::ActionContext::lookup
:
- The output of an action node is emitted by the action itself.
- The output of a constant node is the value provided when the node was
created (see
Node::constant
). - The output of a subsaga node is the output of the subsaga itself. Note that the output of individual nodes from the subsaga DAG is not available to other nodes in this DAG. Only the final output is available.
Implementations§
source§impl Node
impl Node
sourcepub fn action<N: AsRef<str>, L: AsRef<str>, A: SagaType>(
node_name: N,
label: L,
action: &dyn Action<A>
) -> Node
pub fn action<N: AsRef<str>, L: AsRef<str>, A: SagaType>( node_name: N, label: L, action: &dyn Action<A> ) -> Node
sourcepub fn constant<N: AsRef<str>>(node_name: N, value: Value) -> Node
pub fn constant<N: AsRef<str>>(node_name: N, value: Value) -> Node
Make a new constant node (see Node
)
This node immediately emits value
. Why would you want this? Suppose
you’re working with some saga action that expects input to come from
some previous saga node. But in your case, you know the input up front.
You can use this to provide the value to the downstream action.
sourcepub fn subsaga<N1: AsRef<str>, N2: AsRef<str>>(
node_name: N1,
dag: Dag,
params_node_name: N2
) -> Node
pub fn subsaga<N1: AsRef<str>, N2: AsRef<str>>( node_name: N1, dag: Dag, params_node_name: N2 ) -> Node
Make a new subsaga node (see Node
)
This is used to insert a subsaga into another saga. The output of the
subsaga will have name node_name
in the outer saga. The subsaga’s DAG
is described by dag
. Its input parameters will come from node
params_node_name
in the outer saga.