MCPcopy Create free account
hub / github.com/AI45Lab/Code / run_job

Function run_job

core/src/serve/schedule.rs:97–111  ·  view source on GitHub ↗
(job: ScheduledJob, sink: Arc<dyn ScheduleSink>, cancel: CancellationToken)

Source from the content-addressed store, hash-verified

95}
96
97async fn run_job(job: ScheduledJob, sink: Arc<dyn ScheduleSink>, cancel: CancellationToken) {
98 loop {
99 let now = Utc::now();
100 let Some(next) = job.next_fire_after(now) else {
101 return; // never fires again
102 };
103 let wait = (next - now)
104 .to_std()
105 .unwrap_or(std::time::Duration::from_secs(0));
106 tokio::select! {
107 _ = tokio::time::sleep(wait) => sink.fire(&job.spec).await,
108 _ = cancel.cancelled() => return,
109 }
110 }
111}
112
113#[cfg(test)]
114mod tests {

Callers 1

runMethod · 0.85

Calls 2

nowFunction · 0.85
next_fire_afterMethod · 0.80

Tested by

no test coverage detected