pub struct CoordinatorService { /* private fields */ }Expand description
Object-safe coordinator operations backed by SchedulerStore.
Used by chronon-axum handlers and embedded hosts that need job/run APIs without
starting scheduler loops.
Implementations§
Source§impl CoordinatorService
impl CoordinatorService
Sourcepub fn new(store: Arc<dyn SchedulerStore>) -> Self
pub fn new(store: Arc<dyn SchedulerStore>) -> Self
Wraps an existing store; does not start background tasks.
Sourcepub fn store(&self) -> Arc<dyn SchedulerStore>
pub fn store(&self) -> Arc<dyn SchedulerStore>
Underlying store for advanced host queries.
Sourcepub async fn upsert_job(&self, job: Job) -> Result<()>
pub async fn upsert_job(&self, job: Job) -> Result<()>
Insert or update a job, computing partition hash and next cron fire time when needed.
Appends a JobRevision when current_revision changes.
§Examples
use std::sync::Arc;
use chronon_backend_mem::InMemorySchedulerStore;
use chronon_core::{Job, ScheduleKind};
use chronon_runtime::CoordinatorService;
let store = Arc::new(InMemorySchedulerStore::new());
let coordinator = CoordinatorService::new(store);
let mut job = Job::new("nightly", "noop");
job.schedule_kind = ScheduleKind::Manual;
coordinator.upsert_job(job).await?;
assert_eq!(coordinator.list_jobs().await?.len(), 1);End-to-end with a real script: cargo run -p uf-chronon --example script_macro --features mem
(stringly job) or script_handle_job (typed ScriptHandle defaults).
Sourcepub async fn get_job_by_name(&self, job_name: &str) -> Option<Job>
pub async fn get_job_by_name(&self, job_name: &str) -> Option<Job>
Load a job by human-readable job_name.
Sourcepub async fn pause_job(&self, job_id: &str) -> Result<()>
pub async fn pause_job(&self, job_id: &str) -> Result<()>
Disable scheduling for job_id without deleting the row.
Sourcepub async fn resume_job(&self, job_id: &str) -> Result<()>
pub async fn resume_job(&self, job_id: &str) -> Result<()>
Re-enable scheduling for job_id.
Sourcepub async fn list_runs(
&self,
job_id: Option<&str>,
status: Option<&str>,
offset: usize,
limit: usize,
) -> Result<Vec<Run>>
pub async fn list_runs( &self, job_id: Option<&str>, status: Option<&str>, offset: usize, limit: usize, ) -> Result<Vec<Run>>
Paginated run listing with optional job_id and status string filters.
Unrecognized status strings are ignored (no filter).
Sourcepub async fn list_revisions(&self, job_id: &str) -> Result<Vec<JobRevision>>
pub async fn list_revisions(&self, job_id: &str) -> Result<Vec<JobRevision>>
Revision history for job_id, oldest first per store ordering.
Sourcepub async fn run_now(&self, job_id: &str) -> Result<String>
pub async fn run_now(&self, job_id: &str) -> Result<String>
Enqueue an immediate run using the job’s stored params_json.
Returns the new run_id. Errors with ChrononError::JobNotFound when missing.
Manual jobs (ScheduleKind::Manual) are never due for the tick loop; use this
(or HTTP POST /jobs/run_now) to trigger them. Works for any schedule kind.
Runnable sample: cargo run -p uf-chronon --example run_now --features mem.