Struct ockam_node::Context [−][src]
pub struct Context { /* fields omitted */ }
Expand description
Context contains Node state and references to the runtime.
Implementations
Return all addresses of this worker
Create a new context without spawning a full worker
pub async fn start_worker<NM, NW, S>(
&self,
address: S,
worker: NW
) -> Result<()> where
S: Into<AddressSet>,
NM: Message + Send + 'static,
NW: Worker<Context = Context, Message = NM>,
pub async fn start_worker<NM, NW, S>(
&self,
address: S,
worker: NW
) -> Result<()> where
S: Into<AddressSet>,
NM: Message + Send + 'static,
NW: Worker<Context = Context, Message = NM>,
Start a new worker handle at Address
Start a new processor at Address
Shut down a worker by its primary address
Shut down a processor by its address
Signal to the local runtime to shut down immediately
WARNING: calling this function may result in data loss.
It is recommended to use the much safer
Context::stop
function instead!
Signal to the local runtime to shut down
This call will hang until a safe shutdown has been completed.
The default timeout for a safe shutdown is 1 second. You can
change this behaviour by calling
Context::stop_timeout
directly.
Signal to the local runtime to shut down
This call will hang until a safe shutdown has been completed or the desired timeout has been reached.
Send a message via a fully qualified route
Routes can be constructed from a set of Address
es, or via
the RouteBuilder
type. Routes can contain middleware
router addresses, which will re-address messages that need to
be handled by specific domain workers.
Send a message via a fully qualified route using specific Worker address
Routes can be constructed from a set of Address
es, or via
the RouteBuilder
type. Routes can contain middleware
router addresses, which will re-address messages that need to
be handled by specific domain workers.
Forward a transport message to its next routing destination
Similar to Context::send
, but taking a
TransportMessage
, which contains the full destination
route, and calculated return route for this hop.
Note: you most likely want to use
Context::send
instead, unless you are writing an
external router implementation for ockam node.
Receive a message without a timeout
Block the current worker to wait for a typed message
This function may return a Err(FailedLoadData)
if the
underlying worker was shut down, or Err(Timeout)
if the call
was waiting for longer than the default timeout
. Use
receive_timeout
to adjust the
timeout period.
Will return None
if the corresponding worker has been
stopped, or the underlying Node has shut down.
Block to wait for a typed message, with explicit timeout
Block the current worker to wait for a message satisfying a conditional
Will return Err
if the corresponding worker has been
stopped, or the underlying node has shut down. This operation
has a default timeout.
Internally this function calls receive
and .cancel()
in a
loop until a matching message is found.
Assign the current worker to a cluster
A cluster is a set of workers that should be stopped together when the node is stopped or parts of the system are reloaded. This is not to be confused with supervisors!
By adding your worker to a cluster you signal to the runtime that your worker may be depended on by other workers that should be stopped first.
Your cluster name MUST NOT start with _internals.
or
ockam.
!
Clusters are de-allocated in reverse order of their initialisation when the node is stopped.
Return a list of all available worker addresses on a node
Auto Trait Implementations
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more