pub struct CronService { /* private fields */ }Expand description
Cron scheduling service.
Maintains a registry of interval-based jobs. The daemon calls
tick() periodically (e.g., every second) and the service fires
any overdue jobs by sending messages through the A2ARouter.
Implementations§
Source§impl CronService
impl CronService
pub fn new() -> Self
Sourcepub fn set_chain_manager(&mut self, chain_manager: Option<Arc<ChainManager>>)
pub fn set_chain_manager(&mut self, chain_manager: Option<Arc<ChainManager>>)
Attach a chain manager for audit logging.
Sourcepub fn set_governance_gate(&mut self, gate: Option<Arc<GovernanceGate>>)
pub fn set_governance_gate(&mut self, gate: Option<Arc<GovernanceGate>>)
Attach a governance gate for policy enforcement.
Sourcepub fn add_job(
&self,
name: String,
interval_secs: u64,
command: String,
target_pid: Option<Pid>,
) -> Result<CronJob, CronError>
pub fn add_job( &self, name: String, interval_secs: u64, command: String, target_pid: Option<Pid>, ) -> Result<CronJob, CronError>
Add a new cron job. Returns the created job.
§Errors
Returns CronError::GovernanceDenied if the governance gate
rejects the job creation (only when the exochain feature is
enabled and a gate is attached).
Sourcepub fn remove_job(&self, id: &str) -> Result<Option<CronJob>, CronError>
pub fn remove_job(&self, id: &str) -> Result<Option<CronJob>, CronError>
Remove a job by ID. Returns the removed job if it existed.
§Errors
Returns CronError::GovernanceDenied if the governance gate
rejects the job removal (only when the exochain feature is
enabled and a gate is attached).
Sourcepub fn set_enabled(&self, id: &str, enabled: bool) -> Option<CronJob>
pub fn set_enabled(&self, id: &str, enabled: bool) -> Option<CronJob>
Enable or disable a job. Returns the updated job, or None when the
id is unknown. A disabled job is skipped by tick.
Sourcepub fn tick(&self) -> TickResult
pub fn tick(&self) -> TickResult
Tick the scheduler — check all jobs and collect those that are overdue.
Returns the list of job IDs that should fire. The caller is responsible for actually dispatching the messages (to keep CronService decoupled from async A2ARouter).
Sourcepub fn job_snapshot(&self, id: &str) -> Option<CronJob>
pub fn job_snapshot(&self, id: &str) -> Option<CronJob>
Get a snapshot of a job’s current state (for dispatching after tick).
Trait Implementations§
Source§impl Default for CronService
impl Default for CronService
Source§impl SystemService for CronService
impl SystemService for CronService
Source§fn service_type(&self) -> ServiceType
fn service_type(&self) -> ServiceType
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HealthStatus> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HealthStatus> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn health_detail(&self) -> Option<String>
fn health_detail(&self) -> Option<String>
Source§fn liveness_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProbeResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn liveness_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProbeResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn readiness_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProbeResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn readiness_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProbeResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for CronService
impl RefUnwindSafe for CronService
impl Send for CronService
impl Sync for CronService
impl Unpin for CronService
impl UnsafeUnpin for CronService
impl UnwindSafe for CronService
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
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> ⓘ
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> ⓘ
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