Skip to main content

AsterRuntime

Struct AsterRuntime 

Source
pub struct AsterRuntime<S> { /* private fields */ }
Expand description

Product-facing runtime runner built from service and component registrations.

Product entrypoints should register the main service as a component, then register database, task, mail, product, or shutdown bundles in the same chain:

ⓘ
AsterRuntime::builder()
    .component(http_component(...))
    .component(database_component(...))
    .component(task_component(...))
    .run()
    .await?;

Implementations§

Source§

impl AsterRuntime<()>

Source

pub fn builder() -> AsterRuntimeBuilder<()>

Creates a runtime builder.

Source§

impl<S> AsterRuntime<S>
where S: Future,

Source

pub async fn run(self) -> Result<S::Output, AsterRuntimeError>

Runs startup, the main service, before-shutdown hooks, and component shutdown. The owned signal listener is cancelled and joined after the service stops, before cleanup.

When a required startup phase aborts, component shutdown phases still run best-effort before the startup error is returned, so components that already completed startup (connection pools, spawned workers, buffered writers) get a chance to release their resources.

§Errors

Returns a startup report error when a required startup phase aborts, or a shutdown report error after all cleanup phases run if any phase fails or times out. A panicking before-shutdown hook also returns an error after component cleanup. Best-effort product hooks should handle their own errors and return success explicitly. Service panics become AsterRuntimeError::Service after cleanup, preserving secondary hook and shutdown failures without exposing the panic payload. Ordinary service outputs (including product Result::Err values) are returned unchanged when cleanup succeeds. This also covers destruction of the service future after it finishes.

The shared and service cancellation tokens are cancelled before cleanup on every exit. Dropping a polled run future also cancels these tokens, but cannot await cleanup; callers must let run complete to guarantee asynchronous drain and worker joins.

Auto Trait Implementations§

§

impl<S> Freeze for AsterRuntime<S>
where S: Freeze,

§

impl<S> !RefUnwindSafe for AsterRuntime<S>

§

impl<S> Send for AsterRuntime<S>
where S: Send,

§

impl<S> !Sync for AsterRuntime<S>

§

impl<S> Unpin for AsterRuntime<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for AsterRuntime<S>
where S: UnsafeUnpin,

§

impl<S> !UnwindSafe for AsterRuntime<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more