pub struct ServiceContext { /* private fields */ }Expand description
What a service can see of its host and of the run it is in.
Implementations§
Source§impl ServiceContext
impl ServiceContext
Sourcepub fn shutdown(&self) -> &CancellationToken
pub fn shutdown(&self) -> &CancellationToken
Cancelled when the host stops. Long runs should watch it.
Sourcepub fn run(&self) -> u64
pub fn run(&self) -> u64
This run’s number: 1 for the service’s first run, then one more per
launch, the same number its ServiceEvents carry. 0 in
Service::start. To tie an agent run to it, start the agent from
a state you made, whose id you know:
let state = aidaemon_core::RunState::new(
agent.id(),
&format!("service:nightly:{}", ctx.run()),
"Write the nightly report",
);
let run_id = state.run_id; // every Event of the run carries it
let outcome = agent.run_from(state, ctx.shutdown().child_token()).await;Trait Implementations§
Source§impl Clone for ServiceContext
impl Clone for ServiceContext
Source§fn clone(&self) -> ServiceContext
fn clone(&self) -> ServiceContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Forget for ServiceContext
impl Freeze for ServiceContext
impl Move for ServiceContext
impl RefUnwindSafe for ServiceContextwhere
CancellationToken: RefUnwindSafe,
impl Send for ServiceContext
impl Sync for ServiceContext
impl Unpin for ServiceContext
impl UnsafeUnpin for ServiceContextwhere
*const ArcInner<TreeNode> is !null: UnsafeUnpin,
PhantomData<ArcInner<TreeNode>>: UnsafeUnpin,
impl UnwindSafe for ServiceContextwhere
CancellationToken: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more