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
Auto 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