Struct ockam::SystemBuilder
source · [−]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
sourceimpl<C, M> SystemBuilder<C, M> where
C: Send + 'static,
M: Message,
impl<C, M> SystemBuilder<C, M> where
C: Send + 'static,
M: Message,
sourcepub fn add<A, S, H>(
&mut self,
addr: A,
id: S,
handler: H
) -> HandlerBuilder<'_, C, M> where
A: Into<Address>,
S: Into<String>,
H: SystemHandler<C, M> + Send + 'static,
pub fn add<A, S, H>(
&mut self,
addr: A,
id: S,
handler: H
) -> HandlerBuilder<'_, C, M> where
A: Into<Address>,
S: Into<String>,
H: SystemHandler<C, M> + Send + 'static,
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> where
A: Into<Address>,
H: SystemHandler<C, M> + Send + 'static,
pub fn chain_default<A, H>(
&mut self,
addr: A,
prev_id: impl Into<String>,
id: impl Into<String>,
handler: H
) -> HandlerBuilder<'_, C, M> where
A: Into<Address>,
H: SystemHandler<C, M> + Send + 'static,
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> where
A: Into<Address>,
H: SystemHandler<C, M> + Send + 'static,
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> where
A: Into<Address>,
H: SystemHandler<C, M> + Send + 'static,
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
Trait Implementations
sourceimpl<C, M> Clone for SystemBuilder<C, M> where
C: Send + 'static,
M: Message,
impl<C, M> Clone for SystemBuilder<C, M> where
C: Send + 'static,
M: Message,
Auto Trait Implementations
impl<C, M> !RefUnwindSafe for SystemBuilder<C, M>
impl<C, M> Send for SystemBuilder<C, M>
impl<C, M> !Sync for SystemBuilder<C, M>
impl<C, M> Unpin for SystemBuilder<C, M>
impl<C, M> !UnwindSafe for SystemBuilder<C, M>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more