feat(webapp): drainer handler that replays engine.trigger from snapshot
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { RunEngine } from "@internal/run-engine";
|
||||
import type { PrismaClientOrTransaction } from "@trigger.dev/database";
|
||||
import type { MollifierDrainerHandler } from "@trigger.dev/redis-worker";
|
||||
import type { MollifierSnapshot } from "./mollifierSnapshot.server";
|
||||
|
||||
export function isRetryablePgError(err: unknown): boolean {
|
||||
if (!(err instanceof Error)) return false;
|
||||
const msg = err.message ?? "";
|
||||
const code = (err as { code?: string }).code;
|
||||
if (code === "P2024") return true;
|
||||
if (msg.includes("Can't reach database server")) return true;
|
||||
if (msg.includes("Connection lost")) return true;
|
||||
if (msg.includes("ECONNRESET")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function createDrainerHandler(deps: {
|
||||
engine: RunEngine;
|
||||
prisma: PrismaClientOrTransaction;
|
||||
}): MollifierDrainerHandler<MollifierSnapshot> {
|
||||
return async (input) => {
|
||||
await deps.engine.trigger(input.payload as any, deps.prisma);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user