import type { PostProcessor } from './di'; /** Options for the `@scheduled` decorator. */ export interface ScheduledOptions { /** Milliseconds between the starts of consecutive runs (a fixed `setInterval` period, not adjusted for run duration). */ interval: number; /** * When `true`, also fire once immediately at start — or at registration if the * app is already listening — instead of waiting a full `interval`. Default `false`. */ runOnStart?: boolean; } interface ScheduledTask extends ScheduledOptions { run: () => unknown; } /** * Runs `@scheduled` tasks on fixed intervals via `setInterval`. Started by * `app.listen()`, stopped by `app.stop()`. Runs are not re-entrancy-guarded — a * task whose run outlasts its interval will overlap its next run. A failing run * (sync throw or rejected promise) is logged with a `[turnover]` prefix and * swallowed; the interval keeps firing. */ export declare class Scheduler { private readonly tasks; private timers; private started; /** * Register a task (used by the scheduling post-processor). * * @param task - the interval task to register (and start if already running) */ add(task: ScheduledTask): void; /** Begin all registered tasks; idempotent (a no-op once started). `runOnStart` tasks fire synchronously here. */ start(): void; /** Clear every interval timer and reset to unstarted (so {@link Scheduler.start} may run again); an already-running task's current run is neither awaited nor cancelled. */ stop(): void; private schedule; private invoke; } /** * Method decorator: run this method on a fixed interval while the app is * listening. The service must be constructed (inject it, or list it in * `createApp({ listeners })`). * * ```ts * @injectable() class Reminders { * @scheduled({ interval: 60_000 }) sweep() { ... } * } * ``` * * @remarks Fires only while the app is listening. A run that outlasts its * `interval` overlaps the next tick (no re-entrancy guard), and a thrown/rejected * run is logged but not retried — the interval keeps firing regardless. * * @param options - the run `interval` in ms and whether to `runOnStart` * @returns a method decorator that registers the task when its service is constructed */ export declare function scheduled(options: ScheduledOptions): (_value: unknown, context: ClassMethodDecoratorContext) => void; /** * A post-processor that registers a constructed instance's `@scheduled` methods * with the scheduler. Registered automatically by `createApp`. * * @param scheduler - the scheduler to register discovered tasks with * @returns a {@link PostProcessor} that wires each instance's `@scheduled` methods */ export declare function schedulingProcessor(scheduler: Scheduler): PostProcessor; export {}; //# sourceMappingURL=scheduling.d.ts.map