Skip to main content

Service

Trait Service 

Source
pub trait Service:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn start(&self, shutdown: ShutdownToken) -> ServiceFuture<'_>;

    // Provided method
    fn stop(&self) -> ServiceFuture<'_> { ... }
}
Expand description

Async service lifecycle managed by crate::core::ServiceGroup.

Implementors should return from Service::start when the supplied ShutdownToken is cancelled. Service::stop is a best-effort hook used to unblock resources that do not observe the token directly.

Required Methods§

Source

fn name(&self) -> &str

Logical service name used in logs and error messages.

Source

fn start(&self, shutdown: ShutdownToken) -> ServiceFuture<'_>

Starts the service and runs until shutdown or failure.

Provided Methods§

Source

fn stop(&self) -> ServiceFuture<'_>

Stops the service. The default implementation is a no-op.

Implementations on Foreign Types§

Source§

impl Service for Arc<RestService>

Source§

fn name(&self) -> &str

Source§

fn start(&self, shutdown: ShutdownToken) -> ServiceFuture<'_>

Source§

fn stop(&self) -> ServiceFuture<'_>

Implementors§

Source§

impl Service for RestService

Source§

impl Service for TonicHealthService

Source§

impl<F, Fut> Service for FnService<F>
where F: Fn(ShutdownToken) -> Fut + Send + Sync + 'static, Fut: Future<Output = CoreResult<()>> + Send + 'static,

Source§

impl<S> Service for TonicService<S>
where S: Service<Request<Body>, Response = Response<Body>, Error = Infallible> + NamedService + Clone + Send + Sync + 'static, S::Future: Send + 'static,