refactor(mollifier): move DI seam types to the modules that define them
MollifierEvaluateGate and MollifierGetBuffer were defined in the consumer (triggerTask.server.ts) but described the surface of the gate and the buffer accessor respectively. Move each to the module that owns the underlying implementation so the type lives with the producer, not the caller. No behavioural change.
This commit is contained in:
@@ -42,24 +42,16 @@ import type {
|
||||
} from "../types";
|
||||
import {
|
||||
evaluateGate as defaultEvaluateGate,
|
||||
type GateOutcome,
|
||||
type MollifierEvaluateGate,
|
||||
} from "~/v3/mollifier/mollifierGate.server";
|
||||
import { getMollifierBuffer as defaultGetMollifierBuffer } from "~/v3/mollifier/mollifierBuffer.server";
|
||||
import {
|
||||
getMollifierBuffer as defaultGetMollifierBuffer,
|
||||
type MollifierGetBuffer,
|
||||
} from "~/v3/mollifier/mollifierBuffer.server";
|
||||
import { buildBufferedTriggerPayload } from "~/v3/mollifier/bufferedTriggerPayload.server";
|
||||
import { serialiseSnapshot, type MollifierBuffer } from "@trigger.dev/redis-worker";
|
||||
import { serialiseSnapshot } from "@trigger.dev/redis-worker";
|
||||
import { QueueSizeLimitExceededError, ServiceValidationError } from "~/v3/services/common.server";
|
||||
|
||||
export type MollifierEvaluateGate = (
|
||||
inputs: {
|
||||
envId: string;
|
||||
orgId: string;
|
||||
taskId: string;
|
||||
orgFeatureFlags: Record<string, unknown> | null;
|
||||
},
|
||||
) => Promise<GateOutcome>;
|
||||
|
||||
export type MollifierGetBuffer = () => MollifierBuffer | null;
|
||||
|
||||
class NoopTriggerRacepointSystem implements TriggerRacepointSystem {
|
||||
async waitForRacepoint(options: { racepoint: TriggerRacepoints; id: string }): Promise<void> {
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,10 @@ import { env } from "~/env.server";
|
||||
import { logger } from "~/services/logger.server";
|
||||
import { singleton } from "~/utils/singleton";
|
||||
|
||||
// DI seam type for consumers (e.g. triggerTask.server.ts) that need a
|
||||
// nullable buffer accessor at construction time.
|
||||
export type MollifierGetBuffer = () => MollifierBuffer | null;
|
||||
|
||||
function initializeMollifierBuffer(): MollifierBuffer {
|
||||
logger.debug("Initializing mollifier buffer", {
|
||||
host: env.MOLLIFIER_REDIS_HOST,
|
||||
|
||||
@@ -51,6 +51,12 @@ export type GateInputs = {
|
||||
|
||||
export type TripEvaluator = (inputs: GateInputs) => Promise<TripDecision>;
|
||||
|
||||
// DI seam type for consumers (e.g. triggerTask.server.ts) that inject the
|
||||
// gate at construction time. Deliberately narrower than `evaluateGate`'s
|
||||
// real signature — no `deps` param — because consumers only call it with
|
||||
// inputs and rely on the module-level defaults.
|
||||
export type MollifierEvaluateGate = (inputs: GateInputs) => Promise<GateOutcome>;
|
||||
|
||||
export type GateDependencies = {
|
||||
isMollifierEnabled: () => boolean;
|
||||
isShadowModeOn: () => boolean;
|
||||
|
||||
Reference in New Issue
Block a user