aboutsummaryrefslogtreecommitdiff
path: root/services/docker/mail-server/relay/cron.ts
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-04-10 15:12:46 +0800
committerYuqian Yang <crupest@crupest.life>2025-06-05 21:07:37 +0800
commitf1bd9a925804e9f9effe1b180f3d4ab890cf6757 (patch)
tree0ddb044b64f54942a22d0f8a18179f3578247601 /services/docker/mail-server/relay/cron.ts
parent2f6809e0de0fff00a77d2baddb57ac7b947e8566 (diff)
downloadcrupest-f1bd9a925804e9f9effe1b180f3d4ab890cf6757.tar.gz
crupest-f1bd9a925804e9f9effe1b180f3d4ab890cf6757.tar.bz2
crupest-f1bd9a925804e9f9effe1b180f3d4ab890cf6757.zip
feat(mail-server): done aws message id mapping.
Diffstat (limited to 'services/docker/mail-server/relay/cron.ts')
-rw-r--r--services/docker/mail-server/relay/cron.ts43
1 files changed, 0 insertions, 43 deletions
diff --git a/services/docker/mail-server/relay/cron.ts b/services/docker/mail-server/relay/cron.ts
deleted file mode 100644
index bf0a0be..0000000
--- a/services/docker/mail-server/relay/cron.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-export type CronCallback = (task: CronTask) => Promise<void>;
-
-export interface CronTaskConfig {
- readonly name: string;
- readonly interval: number;
- readonly callback: CronCallback;
- readonly startNow?: boolean;
-}
-
-export class CronTask {
- #timerTag: number | null = null;
-
- constructor(public readonly config: CronTaskConfig) {
- if (config.interval <= 0) {
- throw new Error("Cron task interval must be positive.");
- }
-
- if (config.startNow === true) {
- this.start();
- }
- }
-
- get running(): boolean {
- return this.#timerTag != null;
- }
-
- start() {
- if (this.#timerTag == null) {
- this.#timerTag = setInterval(
- this.config.callback,
- this.config.interval,
- this,
- );
- }
- }
-
- stop() {
- if (this.#timerTag != null) {
- clearInterval(this.#timerTag);
- this.#timerTag = null;
- }
- }
-}