[][src]Trait srvzio::service::Service

pub trait Service {
    fn name(&self) -> &'static str;
fn start(&mut self);
fn stop(&mut self); fn await_started(&mut self) { ... }
fn start_and_await(&mut self) { ... }
fn await_stopped(&mut self) { ... }
fn stop_and_await(&mut self) { ... } }

A Service is a black box that does work: it can be started and it can be stopped.

This trait abstracts away the actions that can be done from the outside to a Service. It's up to the specific implementor to make sense of what starting/stopping means.

Note that every method in this trait is by default implemented as a no-op: this leaves to the actual implementor to decide what is fitting to implement, and what is not.

Required methods

fn name(&self) -> &'static str

Service name

fn start(&mut self)

Starts the service

fn stop(&mut self)

Stops the service

Loading content...

Provided methods

fn await_started(&mut self)

Awaits that the service is done starting.

Implement to provide sensible logic to wait for a service to be fully started.

This is usually used after a call to start().

fn start_and_await(&mut self)

Starts the service and waits for it to be done starting.

A graceful start.

fn await_stopped(&mut self)

Awaits that the service is done stopping.

Implement to provide sensible logic to wait for a service to be fully stopped.

This is usually used after a call to stop().

fn stop_and_await(&mut self)

Stops the service and waits for it to be done stopping.

A graceful stop.

Loading content...

Implementors

impl Service for ServiceManager[src]

fn start(&mut self)[src]

Start all registered Services, in order of registration

fn await_started(&mut self)[src]

Wait for all registered Services to be started, in order of registration

fn start_and_await(&mut self)[src]

Start and then wait for all registered Service, in order of registration

This is different then calling start() and then await_started(), because this method will wait for a Service to be started, before moving to the next one.

This can be used to implement a gracefull start.

fn stop(&mut self)[src]

Stop all registered Services, in reverse order of registration

fn await_stopped(&mut self)[src]

Wait for all registered Services to be stopped, in reverse order of registration

fn stop_and_await(&mut self)[src]

Stop and then wait for all registered Service, in reverse order of registration

This is different then calling stop() and then await_stopped(), because this method will wait for a Service to be stopped, before moving to the next one.

This can be used to implement a gracefull stop.

Loading content...