Initialization
Before a process is started, make sure all the necessary information is provided.
In function graph, data types in Resources
are inserted by the consumer, separate from the graph.
In Peace, Item::setup
is run for each item, which allows data types to be inserted into Resources
.
let graph = /* .. */;
let resources = graph.setup(Resources::new()).await?;
// Item1::setup
resources.insert(param1);
// Item2::setup
resources.insert(param2);
// Item3::setup
// no-op
// Item4::setup
resources.insert(param3);
resources.insert(param4);
ℹ️ Note: Each initialization parameter should be specified in each item's
setup
method, even though the parameter is inserted by a predecessor item.This is because when only a subset of the graph is executed, or if the item is used in a different graph, the parameter should still be inserted.
🚧 A wrapper type should conditionally insert the initialization parameter into
Resources