Skip to main content

Component

Trait Component 

Source
pub trait Component {
    // Provided methods
    fn router() -> Router<ServerState> { ... }
    fn initialize(_: &ServerState) -> impl Future<Output = Result<()>> + Send { ... }
    fn run(
        _state: ServerState,
        _cancellation_token: CancellationToken,
    ) -> impl Future<Output = Result<()>> + Send { ... }
}
Expand description

Represents a component in the microservice

Provided Methods§

Source

fn router() -> Router<ServerState>

Returns all the routes exposed by this component.

Source

fn initialize(_: &ServerState) -> impl Future<Output = Result<()>> + Send

Hook to run necessary setup tasks for this component.

Source

fn run( _state: ServerState, _cancellation_token: CancellationToken, ) -> impl Future<Output = Result<()>> + Send

Hook to run background tasks and other long running async executions for this component, e.g. subscribing to a NATS stream and handling messages.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§