Skip to main content

ServiceHost

Struct ServiceHost 

Source
pub struct ServiceHost { /* private fields */ }
Expand description

Runs Services until told to stop.

The rules it schedules by: Every counts from launch to launch, a service never overlaps itself, a failure doubles the wait per failure in a row (up to 2^5, reset by a success), DailyUtc runs once a day at its UTC time (a failed run waits for the next day), due work starts on the next tick or wake-up, and every launch ends with exactly one ServiceEvent::Ended.

Implementations§

Source§

impl ServiceHost

Source

pub fn new(tick: Duration) -> Self

A host that looks for due work every tick.

Source

pub fn max_concurrent(self, limit: usize) -> Self

At most limit Schedule::Every runs at once.

Source

pub fn grace(self, grace: Duration) -> Self

How long a stopping host waits for runs to end before aborting them.

Source

pub fn gate(self, gate: Arc<dyn ServiceGate>) -> Self

Source

pub fn observer(self, observer: Arc<dyn ServiceObserver>) -> Self

Source

pub fn service(self, service: Arc<dyn Service>) -> Self

Source

pub fn waker(&self) -> ServiceWaker

Source

pub async fn run(self, shutdown: CancellationToken)

Run until shutdown is cancelled, then stop launching, drain for the grace period, abort what is left and call each service’s stop.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ServiceHost

§

impl !UnwindSafe for ServiceHost

§

impl Forget for ServiceHost

§

impl Freeze for ServiceHost
where *const u8 is !null: Freeze, PhantomData<Slot>: Freeze, *const ArcInner<Semaphore> is !null: Freeze, PhantomData<ArcInner<Semaphore>>: Freeze, *const ArcInner<dyn ServiceGate> is !null: Freeze, PhantomData<ArcInner<dyn ServiceGate>>: Freeze, *const ArcInner<dyn ServiceObserver> is !null: Freeze, PhantomData<ArcInner<dyn ServiceObserver>>: Freeze, *const ArcInner<Notify> is !null: Freeze, PhantomData<ArcInner<Notify>>: Freeze,

§

impl Move for ServiceHost

§

impl Send for ServiceHost

§

impl Sync for ServiceHost

§

impl Unpin for ServiceHost

§

impl UnsafeUnpin for ServiceHost
where *const u8 is !null: UnsafeUnpin, PhantomData<Slot>: UnsafeUnpin, *const ArcInner<Semaphore> is !null: UnsafeUnpin, PhantomData<ArcInner<Semaphore>>: UnsafeUnpin, *const ArcInner<dyn ServiceGate> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn ServiceGate>>: UnsafeUnpin, *const ArcInner<dyn ServiceObserver> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn ServiceObserver>>: UnsafeUnpin, *const ArcInner<Notify> is !null: UnsafeUnpin, PhantomData<ArcInner<Notify>>: UnsafeUnpin,

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.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.