|
1 | 1 | import { resolveCronTriggerMinIntervalMs } from "../config/cron-limits.js"; |
2 | 2 | import type { CronJob, CronJobState } from "../cron/types.js"; |
3 | 3 | import { pruneMapToMaxSize } from "../infra/map-size.js"; |
4 | | -import type { ProcessSupervisor } from "../process/supervisor/index.js"; |
5 | 4 | import { |
6 | 5 | CronStreamJobOwner, |
7 | 6 | isCronStreamJob, |
8 | 7 | type CronStreamOwnerParams, |
9 | 8 | type CronStreamOwnerSnapshot, |
10 | 9 | type CronStreamStopReason, |
11 | 10 | } from "./cron-stream-job-owner.js"; |
12 | | -import type { CronStreamFireDisposition, CronStreamJob } from "./cron-stream-output.js"; |
| 11 | +import type { CronStreamJob } from "./cron-stream-output.js"; |
13 | 12 |
|
14 | 13 | export type { CronStreamFireDisposition } from "./cron-stream-output.js"; |
15 | 14 |
|
16 | 15 | const MAX_RETIRED_COUNTER_SEEDS = 1_024; |
17 | 16 | const MAX_MUTATION_EPOCHS = 1_024; |
18 | 17 |
|
19 | | -type Logger = { |
20 | | - info: (obj: unknown, msg?: string) => void; |
21 | | - warn: (obj: unknown, msg?: string) => void; |
22 | | -}; |
23 | | - |
24 | 18 | type CronStreamWatchers = { |
25 | 19 | reconcile: (jobs: CronJob[], enabled: boolean, triggersEnabled?: boolean) => Promise<void>; |
26 | 20 | resume: () => void; |
@@ -51,42 +45,13 @@ export function resolveStreamStopReason(input: { |
51 | 45 | } |
52 | 46 |
|
53 | 47 | /** Supervise line-producing cron sources through one serialized owner per job. */ |
54 | | -export function createCronStreamWatchers(params: { |
55 | | - getProcessSupervisor: () => ProcessSupervisor; |
56 | | - /** Test seams; production uses the built-in cadence and retry schedules. */ |
57 | | - minIntervalMs?: number; |
58 | | - retryBackoffMs?: number[]; |
59 | | - updateState: ( |
60 | | - jobId: string, |
61 | | - patch: Partial<CronJobState>, |
62 | | - streamScheduleKey: string, |
63 | | - streamSourceIdentity: string, |
64 | | - ) => Promise<boolean | void>; |
65 | | - retireSource: ( |
66 | | - jobId: string, |
67 | | - streamScheduleKey: string, |
68 | | - streamSourceIdentity: string, |
69 | | - ) => Promise<string | undefined>; |
70 | | - updateCounters?: ( |
71 | | - jobId: string, |
72 | | - counters: Pick<CronJobState, "streamDroppedBatches" | "streamCoalescedBatches">, |
73 | | - ) => Promise<void>; |
74 | | - recordFailure: ( |
75 | | - jobId: string, |
76 | | - error: string, |
77 | | - patch: Partial<CronJobState>, |
78 | | - streamScheduleKey: string, |
79 | | - streamSourceIdentity: string, |
80 | | - ) => Promise<void>; |
81 | | - fireBatch: ( |
82 | | - job: CronJob, |
83 | | - batch: string, |
84 | | - streamScheduleKey: string, |
85 | | - streamSourceIdentity: string, |
86 | | - ) => Promise<CronStreamFireDisposition>; |
87 | | - logger: Logger; |
88 | | - nowMs?: () => number; |
89 | | -}): CronStreamWatchers { |
| 48 | +export function createCronStreamWatchers( |
| 49 | + params: Omit<CronStreamOwnerParams, "minIntervalMs" | "nowMs"> & { |
| 50 | + /** Test seams; production uses the built-in cadence and retry schedules. */ |
| 51 | + minIntervalMs?: number; |
| 52 | + nowMs?: () => number; |
| 53 | + }, |
| 54 | +): CronStreamWatchers { |
90 | 55 | const owners = new Map<string, CronStreamJobOwner>(); |
91 | 56 | const retiredCounterSeeds = new Map< |
92 | 57 | string, |
|
0 commit comments