Setu-TS
    Preparing search index...

    Interface IScheduler

    In-process job scheduler.

    Supports cron expressions (5-field, UTC), fixed-interval recurring jobs, and one-shot delayed jobs. Execution is process-local and time-driven (no durable persistence).

    0.1.0

    interface IScheduler {
        cron<T = unknown>(
            name: string,
            expression: string,
            handler: SchedulerJobHandler<T>,
            options?: ScheduleOptions<T>,
        ): Promise<void>;
        delay<T = unknown>(
            name: string,
            delayMs: number,
            handler: SchedulerJobHandler<T>,
            options?: ScheduleOptions<T>,
        ): Promise<void>;
        every<T = unknown>(
            name: string,
            intervalMs: number,
            handler: SchedulerJobHandler<T>,
            options?: ScheduleOptions<T>,
        ): Promise<void>;
        getNextRun(name: string): Promise<number>;
        pause(name: string): Promise<void>;
        remove(name: string): Promise<void>;
        resume(name: string): Promise<void>;
    }
    Index
    • Schedule a recurring job using a 5-field cron expression (UTC).

      Type Parameters

      • T = unknown

      Parameters

      • name: string

        Unique job name

      • expression: string

        5-field cron expression

      • handler: SchedulerJobHandler<T>

        Callback to invoke on each fire

      • Optionaloptions: ScheduleOptions<T>

        Optional payload and retry config

      Returns Promise<void>

      If a job with name is already scheduled

    • Schedule a one-shot delayed job.

      The job fires once after delayMs and is then auto-removed.

      Type Parameters

      • T = unknown

      Parameters

      • name: string

        Unique job name

      • delayMs: number

        Delay in milliseconds

      • handler: SchedulerJobHandler<T>

        Callback to invoke when the delay expires

      • Optionaloptions: ScheduleOptions<T>

        Optional payload and retry config

      Returns Promise<void>

      If a job with name is already scheduled

    • Schedule a recurring job that fires every intervalMs milliseconds.

      Type Parameters

      • T = unknown

      Parameters

      • name: string

        Unique job name

      • intervalMs: number

        Interval in milliseconds

      • handler: SchedulerJobHandler<T>

        Callback to invoke on each fire

      • Optionaloptions: ScheduleOptions<T>

        Optional payload and retry config

      Returns Promise<void>

      If a job with name is already scheduled

    • Return the next scheduled fire time as epoch milliseconds.

      Parameters

      • name: string

        The job name

      Returns Promise<number>

      Next fire time in epoch ms

      If no job with name exists or the job is paused

    • Pause a scheduled job without dropping its configuration.

      Idempotent — calling pause on an already-paused job is a no-op.

      Parameters

      • name: string

        The job name

      Returns Promise<void>

      If no job with name exists

    • Resume a paused job.

      For cron jobs the next fire is computed from now(). For every jobs the next fire is the next epoch grid boundary of the interval — (floor(now / intervalMs) + 1) * intervalMs — NOT a full interval after now(): grid alignment is what makes replicas started at different instants agree on fire times and distributed-lock slot keys (M70l X10-2). Breaking vs 0.1.0-alpha.8: the released contract stated the interval "restarts from now"; the fire may now come sooner than one full interval after resume (never later). For delay jobs the full original delayMs is re-armed from now().

      Idempotent — calling resume on a running job is a no-op.

      Parameters

      • name: string

        The job name

      Returns Promise<void>

      If no job with name exists