Skip to content

Commit 46e97cf

Browse files
d-csclaude
andcommitted
chore(webapp): unexport internal shard descriptor type and apply format/lint
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent dbc22fd commit 46e97cf

6 files changed

Lines changed: 46 additions & 19 deletions

File tree

apps/webapp/app/db.server.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ import {
3232
} from "./v3/runOpsMigration/splitMode.server";
3333
import { computeRunOpsSplitReadEnabled } from "./v3/runOpsMigration/runOpsSplitReadGate";
3434
import { resolveRunOpsPoolKnobs } from "./v3/runOpsPoolKnobs.server";
35-
import { resolveShardResilience } from "./v3/transactionResilience.server";
36-
import { assertControlPlaneCoresidencyAdvisory } from "./v3/runOpsMigration/controlPlaneCoresidencySentinel.server";
37-
import { DATASOURCE_CONTEXT_KEY, startActiveSpan } from "./v3/tracer.server";
3835
import {
36+
resolveShardResilience,
3937
controlPlaneTransactionResilience,
4038
registerTransactionResilience,
4139
resilienceForClient,
4240
runOpsLegacyTransactionResilience,
4341
runOpsTransactionResilience,
4442
} from "./v3/transactionResilience.server";
43+
import { assertControlPlaneCoresidencyAdvisory } from "./v3/runOpsMigration/controlPlaneCoresidencySentinel.server";
44+
import { DATASOURCE_CONTEXT_KEY, startActiveSpan } from "./v3/tracer.server";
4545
import type { Span } from "@opentelemetry/api";
4646
import { context, trace } from "@opentelemetry/api";
4747
import { queryPerformanceMonitor } from "./utils/queryPerformanceMonitor.server";
@@ -277,7 +277,7 @@ export const webhookReplica: WebhookReplicaDatabase = singleton("webhookReplica"
277277

278278
type RunOpsClients = { writer: PrismaClient; replica: PrismaReplicaClient };
279279
type NewRunOpsClients = { writer: RunOpsPrismaClient; replica: RunOpsPrismaClient };
280-
export type ShardTopologyDescriptor = {
280+
type ShardTopologyDescriptor = {
281281
key: string;
282282
url?: string;
283283
replicaUrl?: string;
@@ -1060,7 +1060,9 @@ function buildRunOpsClient({
10601060
}): RunOpsPrismaClient {
10611061
const isWriter = role === "writer";
10621062
const setupLabel = isWriter ? "run-ops prisma client" : "run-ops read replica connection";
1063-
const connectedLabel = isWriter ? "run-ops prisma client connected" : "run-ops read replica connected";
1063+
const connectedLabel = isWriter
1064+
? "run-ops prisma client connected"
1065+
: "run-ops read replica connected";
10641066

10651067
const connectionUrl = buildPrismaConnectionUrl(url, {
10661068
connectionLimit: connectionLimit.toString(),
@@ -1111,7 +1113,11 @@ function buildRunOpsClient({
11111113
client.$on("error", (log) =>
11121114
// The writer bridges P2002 -> 422 at the store boundary, so its infra errors are logged once
11131115
// there (ignoreError). Replica errors are not on that write path, so they log normally.
1114-
logger.error("RunOpsPrismaClient error", { clientType, event: log, ...(isWriter ? { ignoreError: true } : {}) })
1116+
logger.error("RunOpsPrismaClient error", {
1117+
clientType,
1118+
event: log,
1119+
...(isWriter ? { ignoreError: true } : {}),
1120+
})
11151121
);
11161122
}
11171123

apps/webapp/app/v3/runOpsMigration/mintShardAssignment.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,9 @@ describe("routableKeys bound (the shard descriptor keys this deployment can rout
485485
});
486486

487487
it("returns new when the active list holds only non-routable keys (fail-safe to gen-1)", () => {
488-
expect(
489-
computeMintShard({ id: "env_1" }, deps({ set: ["z"] }, { routableKeys: ["a"] }))
490-
).toBe("new");
488+
expect(computeMintShard({ id: "env_1" }, deps({ set: ["z"] }, { routableKeys: ["a"] }))).toBe(
489+
"new"
490+
);
491491
});
492492

493493
it("rejects a per-org pin to a non-routable key and falls through to the hash", () => {
@@ -501,7 +501,10 @@ describe("routableKeys bound (the shard descriptor keys this deployment can rout
501501
it("with no routableKeys given, behaviour is unchanged", () => {
502502
const ids = envIds(200);
503503
for (const id of ids) {
504-
const withBound = computeMintShard({ id }, deps({ set: ["a", "b"] }, { routableKeys: ["a", "b"] }));
504+
const withBound = computeMintShard(
505+
{ id },
506+
deps({ set: ["a", "b"] }, { routableKeys: ["a", "b"] })
507+
);
505508
const without = computeMintShard({ id }, deps({ set: ["a", "b"] }));
506509
expect(withBound).toBe(without);
507510
}

apps/webapp/app/v3/runOpsPoolKnobs.server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ export function resolveRunOpsPoolKnobs(
5555

5656
return {
5757
writerPoolTimeout:
58-
k?.writerPoolTimeout ??
59-
env.RUN_OPS_DATABASE_WRITER_POOL_TIMEOUT ??
60-
env.DATABASE_POOL_TIMEOUT,
58+
k?.writerPoolTimeout ?? env.RUN_OPS_DATABASE_WRITER_POOL_TIMEOUT ?? env.DATABASE_POOL_TIMEOUT,
6159
writerConnectionTimeout:
6260
k?.writerConnectionTimeout ??
6361
env.RUN_OPS_DATABASE_WRITER_CONNECTION_TIMEOUT ??

apps/webapp/app/v3/runStore.server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { PostgresRunStore, RoutingRunStore, type RunStore } from "@internal/run-store";
2-
import { ownerEngine, resolveShard, type Residency, type ShardKey } from "@trigger.dev/core/v3/isomorphic";
2+
import {
3+
ownerEngine,
4+
resolveShard,
5+
type Residency,
6+
type ShardKey,
7+
} from "@trigger.dev/core/v3/isomorphic";
38
import type { PrismaClient, PrismaReplicaClient } from "@trigger.dev/database";
49
import type { RunOpsPrismaClient } from "@internal/run-ops-database";
510
import {

apps/webapp/test/runOpsShards.test.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,39 @@ describe("parseRunOpsShards", () => {
3535
expect(run(JSON.stringify([{ ...valid, key: "ab" }])).success).toBe(false);
3636
});
3737
it("fails on duplicate keys", () => {
38-
const b = { ...valid, replication: { slotName: "s2", publicationName: "p2", originGeneration: 3 } };
38+
const b = {
39+
...valid,
40+
replication: { slotName: "s2", publicationName: "p2", originGeneration: 3 },
41+
};
3942
expect(run(JSON.stringify([valid, b])).success).toBe(false);
4043
});
4144
it("fails on duplicate origin generations", () => {
4245
const b = { ...valid, key: "b", url: "postgres://h/b" };
4346
expect(run(JSON.stringify([valid, b])).success).toBe(false);
4447
});
4548
it("fails when both url and aliasOf are set", () => {
46-
expect(run(JSON.stringify([{ key: "a", region: "x", url: "postgres://h/db", aliasOf: "new" }])).success).toBe(false);
49+
expect(
50+
run(JSON.stringify([{ key: "a", region: "x", url: "postgres://h/db", aliasOf: "new" }]))
51+
.success
52+
).toBe(false);
4753
});
4854
it("accepts aliasOf without url or replication", () => {
4955
expect(run(JSON.stringify([{ key: "a", region: "x", aliasOf: "new" }])).success).toBe(true);
5056
});
5157
it("fails on an origin generation below 2 or above 255", () => {
52-
const mk = (g: number) => run(JSON.stringify([{ ...valid, replication: { slotName: "s", publicationName: "p", originGeneration: g } }]));
58+
const mk = (g: number) =>
59+
run(
60+
JSON.stringify([
61+
{ ...valid, replication: { slotName: "s", publicationName: "p", originGeneration: g } },
62+
])
63+
);
5364
expect(mk(1).success).toBe(false);
5465
expect(mk(256).success).toBe(false);
5566
});
5667
it("fails when a non-aliased descriptor omits replication", () => {
57-
expect(run(JSON.stringify([{ key: "a", region: "x", url: "postgres://h/db" }])).success).toBe(false);
68+
expect(run(JSON.stringify([{ key: "a", region: "x", url: "postgres://h/db" }])).success).toBe(
69+
false
70+
);
5871
});
5972
});
6073

apps/webapp/test/transactionResilience.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ describe("resolveTransactionResilience per-shard", () => {
99
});
1010

1111
it("accepts an arbitrary pool label and honours a maxWait override", () => {
12-
expect(() => resolveTransactionResilience("run-ops-shard-z", { maxWaitMs: 1234 })).not.toThrow();
12+
expect(() =>
13+
resolveTransactionResilience("run-ops-shard-z", { maxWaitMs: 1234 })
14+
).not.toThrow();
1315
expect(resolveTransactionResilience("run-ops-shard-z", { maxWaitMs: 1234 }).maxWait).toBe(1234);
1416
});
1517
});

0 commit comments

Comments
 (0)