|
1 | 1 | import { createRedisClusterClient, type Cluster } from "@internal/redis"; |
2 | 2 | import { RedisSnapshotStore, type SnapshotStoreMetrics } from "@internal/run-store"; |
3 | 3 |
|
| 4 | +const DEFAULT_COMPLETED_TTL_MS = 4 * 24 * 60 * 60 * 1_000; |
4 | 5 | const COMMAND_TIMEOUT_MS = 1_000; |
5 | 6 | const CONNECT_TIMEOUT_MS = 500; |
6 | 7 | const POLICY_CHECK_INTERVAL_MS = 30_000; |
7 | | -const COMPLETED_TTL_MS = 4 * 24 * 60 * 60 * 1_000; |
8 | 8 |
|
9 | 9 | /** Infrastructure only. Rollout modes belong to the existing polled flags, not this URL. */ |
10 | 10 | export function snapshotClusterOptions(endpoint: string) { |
@@ -45,7 +45,12 @@ export function snapshotClusterOptions(endpoint: string) { |
45 | 45 | */ |
46 | 46 | export function createSnapshotConnection( |
47 | 47 | endpoint: string, |
48 | | - options: { metrics?: SnapshotStoreMetrics; onError?: (error: Error) => void } = {} |
| 48 | + options: { |
| 49 | + metrics?: SnapshotStoreMetrics; |
| 50 | + onError?: (error: Error) => void; |
| 51 | + /** How long a finished run's snapshot state stays in the store. */ |
| 52 | + completedTtlMs?: number; |
| 53 | + } = {} |
49 | 54 | ) { |
50 | 55 | const clientOptions = snapshotClusterOptions(endpoint); |
51 | 56 | let client: Cluster | undefined; |
@@ -114,7 +119,7 @@ export function createSnapshotConnection( |
114 | 119 | getStore: () => |
115 | 120 | (store ??= new RedisSnapshotStore({ |
116 | 121 | client: getClient(), |
117 | | - completedTtlMs: COMPLETED_TTL_MS, |
| 122 | + completedTtlMs: options.completedTtlMs ?? DEFAULT_COMPLETED_TTL_MS, |
118 | 123 | beforeCommand, |
119 | 124 | metrics: options.metrics, |
120 | 125 | })), |
|
0 commit comments