authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-10-05 19:30:02-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-05 19:30:02-07:00
log8bd7745f0af918582807326d90e58d59324bb2a6
treee3e99a7f12e512a02148e8b91ec050960161cb38
parent31d0c8a4f47ead36c9a63ac4d3bf27b55c05095a
signature Signed by PGP key B5690EEEBB952194

refactor(relay): import HookInboxObject once, as a namespace (#16307)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

2 files changed, 10 insertions(+), 13 deletions(-)

infra/relay/src/hooks/HookInboxObject.ts+7-9
......@@ -23,14 +23,6 @@ const RUN_FAILURE_RETRY_MS = 60_000;
2323
2424type Call<A> = Effect.Effect<A, never, Alchemy.RuntimeContext>;
2525
26export 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
......@@ -38,7 +30,13 @@ export interface HookInboxObjectShape {
3830 */
3931export 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+3-4
......@@ -67,8 +67,7 @@ import * as MobileRegistrations from "./agentActivity/MobileRegistrations.ts";
6767import * as HookForwarder from "./hooks/HookForwarder.ts";
6868import * as HeldHooks from "./hooks/HeldHooks.ts";
6969import * as HookInbox from "./hooks/HookInbox.ts";
70import { HookInboxObject } from "./hooks/HookInboxObject.ts";
71import * as HookInboxObjectLayer from "./hooks/HookInboxObject.ts";
70import * as HookInboxObject from "./hooks/HookInboxObject.ts";
7271
7372const 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.