canic_core/ops/service.rs
1use crate::ops::{
2 OpsError,
3 pool::PoolOps,
4 random::RandomOps,
5 runtime::{cycles::CycleTrackerOps, log::LogOps},
6};
7
8///
9/// TimerService
10/// Coordinates periodic background services (timers) for Canic canisters.
11///
12
13pub struct TimerService;
14
15impl TimerService {
16 /// Start timers that should run on all canisters.
17 pub fn start_all() {
18 CycleTrackerOps::start();
19 LogOps::start_retention();
20 RandomOps::start();
21 }
22
23 /// Start timers that should run only on root canisters.
24 pub fn start_all_root() {
25 OpsError::require_root().expect("TimerService::start_all_root called from non-root");
26
27 // start shared timers too
28 Self::start_all();
29
30 // root-only services
31 PoolOps::start();
32 }
33}