Skip to main content

CoordinatorService

Struct CoordinatorService 

Source
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

Source

pub fn new(store: Arc<dyn SchedulerStore>) -> Self

Wraps an existing store; does not start background tasks.

Source

pub fn store(&self) -> Arc<dyn SchedulerStore>

Underlying store for advanced host queries.

Source

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).

Source

pub async fn get_job(&self, job_id: &str) -> Option<Job>

Load a job by stable job_id.

Source

pub async fn get_job_by_name(&self, job_name: &str) -> Option<Job>

Load a job by human-readable job_name.

Source

pub async fn list_jobs(&self) -> Result<Vec<Job>>

All jobs in the store.

§Errors

Returns a storage error when the underlying store fails.

Source

pub async fn pause_job(&self, job_id: &str) -> Result<()>

Disable scheduling for job_id without deleting the row.

Source

pub async fn resume_job(&self, job_id: &str) -> Result<()>

Re-enable scheduling for job_id.

Source

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).

Source

pub async fn get_run(&self, run_id: &str) -> Result<Option<Run>>

Load a single run by run_id.

Source

pub async fn list_revisions(&self, job_id: &str) -> Result<Vec<JobRevision>>

Revision history for job_id, oldest first per store ordering.

Source

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.

Source

pub async fn run_now_with_params( &self, job_id: &str, params_override: Option<Value>, ) -> Result<String>

Enqueue an immediate run, optionally overriding params JSON.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more