Skip to content

Commit 7d74b8a

Browse files
committed
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.
1 parent 1e087e2 commit 7d74b8a

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

apps/webapp/app/runEngine/services/triggerTask.server.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,16 @@ import type {
4242
} from "../types";
4343
import {
4444
evaluateGate as defaultEvaluateGate,
45-
type GateOutcome,
45+
type MollifierEvaluateGate,
4646
} from "~/v3/mollifier/mollifierGate.server";
47-
import { getMollifierBuffer as defaultGetMollifierBuffer } from "~/v3/mollifier/mollifierBuffer.server";
47+
import {
48+
getMollifierBuffer as defaultGetMollifierBuffer,
49+
type MollifierGetBuffer,
50+
} from "~/v3/mollifier/mollifierBuffer.server";
4851
import { buildBufferedTriggerPayload } from "~/v3/mollifier/bufferedTriggerPayload.server";
49-
import { serialiseSnapshot, type MollifierBuffer } from "@trigger.dev/redis-worker";
52+
import { serialiseSnapshot } from "@trigger.dev/redis-worker";
5053
import { QueueSizeLimitExceededError, ServiceValidationError } from "~/v3/services/common.server";
5154

52-
export type MollifierEvaluateGate = (
53-
inputs: {
54-
envId: string;
55-
orgId: string;
56-
taskId: string;
57-
orgFeatureFlags: Record<string, unknown> | null;
58-
},
59-
) => Promise<GateOutcome>;
60-
61-
export type MollifierGetBuffer = () => MollifierBuffer | null;
62-
6355
class NoopTriggerRacepointSystem implements TriggerRacepointSystem {
6456
async waitForRacepoint(options: { racepoint: TriggerRacepoints; id: string }): Promise<void> {
6557
return;

apps/webapp/app/v3/mollifier/mollifierBuffer.server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { env } from "~/env.server";
33
import { logger } from "~/services/logger.server";
44
import { singleton } from "~/utils/singleton";
55

6+
// DI seam type for consumers (e.g. triggerTask.server.ts) that need a
7+
// nullable buffer accessor at construction time.
8+
export type MollifierGetBuffer = () => MollifierBuffer | null;
9+
610
function initializeMollifierBuffer(): MollifierBuffer {
711
logger.debug("Initializing mollifier buffer", {
812
host: env.MOLLIFIER_REDIS_HOST,

apps/webapp/app/v3/mollifier/mollifierGate.server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export type GateInputs = {
5151

5252
export type TripEvaluator = (inputs: GateInputs) => Promise<TripDecision>;
5353

54+
// DI seam type for consumers (e.g. triggerTask.server.ts) that inject the
55+
// gate at construction time. Deliberately narrower than `evaluateGate`'s
56+
// real signature — no `deps` param — because consumers only call it with
57+
// inputs and rely on the module-level defaults.
58+
export type MollifierEvaluateGate = (inputs: GateInputs) => Promise<GateOutcome>;
59+
5460
export type GateDependencies = {
5561
isMollifierEnabled: () => boolean;
5662
isShadowModeOn: () => boolean;

0 commit comments

Comments
 (0)