2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-11-01 14:57:55 -04:00
|
|
|
|
2024-10-12 17:23:49 -04:00
|
|
|
use crate::CronError;
|
2023-11-01 14:57:55 -04:00
|
|
|
use async_trait::async_trait;
|
|
|
|
|
|
|
|
pub trait CronHandler {
|
|
|
|
type EH: CronHandle + 'static;
|
|
|
|
|
2024-10-12 17:23:49 -04:00
|
|
|
fn create(&self, spec: CronSpec) -> Result<Self::EH, CronError>;
|
2023-11-01 14:57:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait(?Send)]
|
|
|
|
pub trait CronHandle {
|
2024-10-12 17:23:49 -04:00
|
|
|
async fn next(&self, prev_success: bool) -> Result<bool, CronError>;
|
2023-11-01 14:57:55 -04:00
|
|
|
fn close(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct CronSpec {
|
|
|
|
pub name: String,
|
|
|
|
pub cron_schedule: String,
|
|
|
|
pub backoff_schedule: Option<Vec<u32>>,
|
|
|
|
}
|