Skip to content

Commit 8bd7745

Browse files
refactor(relay): import HookInboxObject once, as a namespace (pingdotgg#16307)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 31d0c8a commit 8bd7745

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎infra/relay/src/hooks/HookInboxObject.ts‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,20 @@ const RUN_FAILURE_RETRY_MS = 60_000;
2323

2424
type Call<A> = Effect.Effect<A, never, Alchemy.RuntimeContext>;
2525

26-
export interface HookInboxObjectShape {
27-
/** Holds a request for `baseUrl`; false when the inbox is full and nothing was stored. */
28-
readonly hold: (hook: HookInboxStore.HeldHook, baseUrl: string) => Call<boolean>;
29-
/** The environment is back at `baseUrl`: deliver what is waiting now. */
30-
readonly wake: (baseUrl: string) => Call<boolean>;
31-
readonly clear: () => Call<void>;
32-
}
33-
3426
/**
3527
* One per managed endpoint, addressed by endpoint key. Holds webhook requests
3628
* the environment could not take, in SQLite, and pushes them back through
3729
* its tunnel from the alarm, oldest first, backing off while it stays away.
3830
*/
3931
export class HookInboxObject extends Cloudflare.DurableObject<
4032
HookInboxObject,
41-
HookInboxObjectShape
33+
{
34+
/** Holds a request for `baseUrl`; false when the inbox is full and nothing was stored. */
35+
readonly hold: (hook: HookInboxStore.HeldHook, baseUrl: string) => Call<boolean>;
36+
/** The environment is back at `baseUrl`: deliver what is waiting now. */
37+
readonly wake: (baseUrl: string) => Call<boolean>;
38+
readonly clear: () => Call<void>;
39+
}
4240
>()("HookInboxObject") {}
4341

4442
/**

‎infra/relay/src/worker.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ import * as MobileRegistrations from "./agentActivity/MobileRegistrations.ts";
6767
import * as HookForwarder from "./hooks/HookForwarder.ts";
6868
import * as HeldHooks from "./hooks/HeldHooks.ts";
6969
import * as HookInbox from "./hooks/HookInbox.ts";
70-
import { HookInboxObject } from "./hooks/HookInboxObject.ts";
71-
import * as HookInboxObjectLayer from "./hooks/HookInboxObject.ts";
70+
import * as HookInboxObject from "./hooks/HookInboxObject.ts";
7271

7372
const layerWebcrypto = Layer.succeed(
7473
Crypto.Crypto,
@@ -201,7 +200,7 @@ export const layer = Api.make(
201200
period: HookForwarder.RELAY_HOOK_ENDPOINT_RATE_LIMIT.periodSeconds,
202201
},
203202
});
204-
const hookInboxes = yield* HookInboxObject;
203+
const hookInboxes = yield* HookInboxObject.HookInboxObject;
205204

206205
//
207206
// 3. Runtime layers and app construction
@@ -470,7 +469,7 @@ export const layer = Api.make(
470469
Layer.provideMerge(Cloudflare.Tunnel.ReadWriteTunnelBinding),
471470
Layer.provideMerge(Cloudflare.DNS.ReadWriteDnsHttp),
472471
Layer.provideMerge(Cloudflare.Workers.RateLimitBinding),
473-
Layer.provideMerge(HookInboxObjectLayer.layer),
472+
Layer.provideMerge(HookInboxObject.layer),
474473
// The worker runtime opens its own HTTP span around ours. For webhook
475474
// paths it would record the raw URL, token included, and adopt the
476475
// sender's traceparent, so only our redacted span covers those.

0 commit comments

Comments
 (0)