-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathupdateMetadataInstance.server.ts
More file actions
29 lines (28 loc) · 1.21 KB
/
Copy pathupdateMetadataInstance.server.ts
File metadata and controls
29 lines (28 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { singleton } from "~/utils/singleton";
import { env } from "~/env.server";
import { UpdateMetadataService } from "./updateMetadata.server";
import { prisma } from "~/db.server";
import { publishChangeRecord } from "~/services/realtime/runChangeNotifierInstance.server";
export const updateMetadataService = singleton(
"update-metadata-service",
() =>
new UpdateMetadataService({
prisma,
flushIntervalMs: env.BATCH_METADATA_OPERATIONS_FLUSH_INTERVAL_MS,
flushEnabled: env.BATCH_METADATA_OPERATIONS_FLUSH_ENABLED === "1",
flushLoggingEnabled: env.BATCH_METADATA_OPERATIONS_FLUSH_LOGGING_ENABLED === "1",
maximumSize: env.TASK_RUN_METADATA_MAXIMUM_SIZE,
logLevel: env.BATCH_METADATA_OPERATIONS_FLUSH_LOGGING_ENABLED === "1" ? "debug" : "info",
// Buffered (parent/root) operations land via the flusher, not the caller's request —
// publish here so those changes wake live feeds too (no-op when the backend is off).
onRunFlushed: (run) => {
publishChangeRecord({
runId: run.runId,
envId: run.environmentId,
tags: run.tags,
batchId: run.batchId,
updatedAtMs: run.updatedAtMs,
});
},
})
);