summaryrefslogtreecommitdiff
path: root/ext/cron/interface.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/cron/interface.rs')
-rw-r--r--ext/cron/interface.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/cron/interface.rs b/ext/cron/interface.rs
new file mode 100644
index 000000000..c70988788
--- /dev/null
+++ b/ext/cron/interface.rs
@@ -0,0 +1,23 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+use async_trait::async_trait;
+use deno_core::error::AnyError;
+
+pub trait CronHandler {
+ type EH: CronHandle + 'static;
+
+ fn create(&self, spec: CronSpec) -> Result<Self::EH, AnyError>;
+}
+
+#[async_trait(?Send)]
+pub trait CronHandle {
+ async fn next(&self, prev_success: bool) -> Result<bool, AnyError>;
+ fn close(&self);
+}
+
+#[derive(Clone)]
+pub struct CronSpec {
+ pub name: String,
+ pub cron_schedule: String,
+ pub backoff_schedule: Option<Vec<u32>>,
+}