pub struct Node<T: NodeImpl> { /* private fields */ }Expand description
Wrapper that manages the lifecycle of a NodeImpl.
This provides:
- State management
- Lifecycle orchestration
- Error handling
- Health monitoring
Implementations§
Source§impl<T: NodeImpl> Node<T>
impl<T: NodeImpl> Node<T>
Sourcepub async fn from_config(config: T::Config) -> Result<Self>
pub async fn from_config(config: T::Config) -> Result<Self>
Create a new node from a configuration.
This calls NodeImpl::init() and wraps the result in a Node.
§Errors
Returns an error if initialization fails.
Sourcepub async fn start(&self, ctx: Context) -> Result<()>
pub async fn start(&self, ctx: Context) -> Result<()>
Start the node with the given context.
This orchestrates the full lifecycle:
- Transition to Running state
- Call
run() - Call
shutdown()on completion or error - Transition to final state
§Errors
Returns an error if the node fails during execution.
Sourcepub async fn shutdown(&self) -> Result<()>
pub async fn shutdown(&self) -> Result<()>
Gracefully shutdown the node.
This calls shutdown() and transitions to Stopped state.
Sourcepub async fn health_check(&self) -> HealthStatus
pub async fn health_check(&self) -> HealthStatus
Perform a health check on the node.
Sourcepub async fn is_healthy(&self) -> bool
pub async fn is_healthy(&self) -> bool
Check if the node is healthy.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Node<T>
impl<T> !RefUnwindSafe for Node<T>
impl<T> Send for Node<T>
impl<T> Sync for Node<T>
impl<T> Unpin for Node<T>
impl<T> !UnwindSafe for Node<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more