Trait bee_runtime::node::Node
source · [−]pub trait Node: Send + Sized + 'static {
type Builder: NodeBuilder<Self>;
type Backend: StorageBackend;
type Error: Error;
fn stop<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where
Self: 'async_trait;
fn spawn<W, G, F>(&mut self, g: G)
where
W: Worker<Self>,
G: FnOnce(Receiver<()>) -> F,
F: Future<Output = ()> + Send + 'static;
fn worker<W>(&self) -> Option<&W>
where
W: Worker<Self> + Send + Sync;
fn register_resource<R: Any + Send + Sync>(&mut self, res: R);
fn remove_resource<R: Any + Send + Sync>(&mut self) -> Option<R>;
fn resource<R: Any + Send + Sync>(&self) -> ResourceHandle<R>;
fn info(&self) -> ResourceHandle<NodeInfo> { ... }
fn storage(&self) -> ResourceHandle<Self::Backend> { ... }
fn bus(&self) -> ResourceHandle<Bus<'static>> { ... }
}
Expand description
A trait representing a node framework through which node workers may communicate.
Required Associated Types
type Builder: NodeBuilder<Self>
type Builder: NodeBuilder<Self>
The builder type used to create instances of this node.
type Backend: StorageBackend
type Backend: StorageBackend
The storage backend used by this node.
Required Methods
Stop the node, ending the execution of all workers in a timely manner.
Spawn a new node task associated with the given worker.
The task will be shut down with the worker to preserve topological worker ordering.
Get a reference to the state of a worker.
fn register_resource<R: Any + Send + Sync>(&mut self, res: R)
fn register_resource<R: Any + Send + Sync>(&mut self, res: R)
Register a new resource with the node such that other workers may access it via Node::resource
.
Attempt to remove a resource from the node, returning None
if no such resource was registered with the node.
Provided Methods
fn info(&self) -> ResourceHandle<NodeInfo>
fn info(&self) -> ResourceHandle<NodeInfo>
Obtain an owning handle to the node’s info.
fn storage(&self) -> ResourceHandle<Self::Backend>
fn storage(&self) -> ResourceHandle<Self::Backend>
Obtain an owning handle to the node’s storage backend.
fn bus(&self) -> ResourceHandle<Bus<'static>>
fn bus(&self) -> ResourceHandle<Bus<'static>>
Obtain an owning handle to the node’s event bus.