pub struct Context { /* private fields */ }
Expand description

Context contains Node state and references to the runtime.

Implementations

Return runtime clone

Return the primary worker address

Return all addresses of this worker

Create a new context without spawning a full worker

Start a new worker handle at Address

TODO: Worker builder?

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 to another address associated with this worker

This function is a simple wrapper around Self::send() which validates the address given to it and will reject invalid addresses.

Send a message via a fully qualified route

Routes can be constructed from a set of Addresses, 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 Addresses, 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

Register a router for a specific address type

Set access control for current context

Wait for a particular address to become “ready”

Trait Implementations

Try cloning a object and return an Err in case of failure.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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