Struct ockam::SystemBuilder
source · pub struct SystemBuilder<C, M>{ /* private fields */ }
Expand description
An abstraction to build a worker system graph
When creating a worker system it’s important to initialise each handler with the set of internal addresses that it must communicate with. This structure aims to make initialisation easier.
Implementations§
source§impl<C, M> SystemBuilder<C, M>
impl<C, M> SystemBuilder<C, M>
sourcepub fn add<A, S, H>(
&mut self,
addr: A,
id: S,
handler: H
) -> HandlerBuilder<'_, C, M>
pub fn add<A, S, H>( &mut self, addr: A, id: S, handler: H ) -> HandlerBuilder<'_, C, M>
Add a new handler to this SystemBuilder
You must at least provide ONE route path (via .default(addr)
or .condition(cond, addr)
), or else initialisation will
fail.
sourcepub fn get_addr(&self, id: impl Into<String>) -> Option<Address>
pub fn get_addr(&self, id: impl Into<String>) -> Option<Address>
Get the address of a previously added SystemHandler
sourcepub fn set_entry<A: Into<Address>>(&mut self, addr: A)
pub fn set_entry<A: Into<Address>>(&mut self, addr: A)
Specify an entry-point for the soon-to-be-built system
sourcepub fn chain_default<A, H>(
&mut self,
addr: A,
prev_id: impl Into<String>,
id: impl Into<String>,
handler: H
) -> HandlerBuilder<'_, C, M>
pub fn chain_default<A, H>( &mut self, addr: A, prev_id: impl Into<String>, id: impl Into<String>, handler: H ) -> HandlerBuilder<'_, C, M>
Add a new handler to the builder, re-addressing the previous handler’s “default” route to this one
sourcepub fn chain_for<A, H>(
&mut self,
rule: impl Into<String>,
addr: A,
prev_id: impl Into<String>,
id: impl Into<String>,
handler: H
) -> HandlerBuilder<'_, C, M>
pub fn chain_for<A, H>( &mut self, rule: impl Into<String>, addr: A, prev_id: impl Into<String>, id: impl Into<String>, handler: H ) -> HandlerBuilder<'_, C, M>
Add a new handler to the builder, re-addressing the previous handler’s named route to this one
sourcepub fn readdress(&mut self, fin_addr: &Address)
pub fn readdress(&mut self, fin_addr: &Address)
Re-address every system handler in order to clone it
When initialising a worker system builder you setup handlers and routes between them. However when cloning the worker system all addresses need to be re-addressed in order to allow a second instance of every address to exist on the same node.
This problem may be solved by having scoped addresses in the future.
This function assigns a new address to every handler and then changes routes that point to the old addresses. Any route that is not in the internal set (i.e. the fin address routes) are replaced with the externally provided fin-address.
sourcepub async fn finalise(self, ctx: &mut C) -> Result<WorkerSystem<C, M>>
pub async fn finalise(self, ctx: &mut C) -> Result<WorkerSystem<C, M>>
Create a WorkerSystem
and pre-initialise every SystemHandler