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;...@@ -23,14 +23,6 @@ const RUN_FAILURE_RETRY_MS = 60_000;
2323
24type Call<A> = Effect.Effect<A, never, Alchemy.RuntimeContext>;24type 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
34/**26/**
35 * One per managed endpoint, addressed by endpoint key. Holds webhook requests27 * One per managed endpoint, addressed by endpoint key. Holds webhook requests
36 * the environment could not take, in SQLite, and pushes them back through28 * the environment could not take, in SQLite, and pushes them back through
...@@ -38,7 +30,13 @@ export interface HookInboxObjectShape {...@@ -38,7 +30,13 @@ export interface HookInboxObjectShape {
38 */30 */
39export class HookInboxObject extends Cloudflare.DurableObject<31export class HookInboxObject extends Cloudflare.DurableObject<
40 HookInboxObject,32 HookInboxObject,
41 HookInboxObjectShape33 {
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 }
42>()("HookInboxObject") {}40>()("HookInboxObject") {}
4341
44/**42/**
infra/relay/src/worker.ts+3-4
...@@ -67,8 +67,7 @@ import * as MobileRegistrations from "./agentActivity/MobileRegistrations.ts";...@@ -67,8 +67,7 @@ import * as MobileRegistrations from "./agentActivity/MobileRegistrations.ts";
67import * as HookForwarder from "./hooks/HookForwarder.ts";67import * as HookForwarder from "./hooks/HookForwarder.ts";
68import * as HeldHooks from "./hooks/HeldHooks.ts";68import * as HeldHooks from "./hooks/HeldHooks.ts";
69import * as HookInbox from "./hooks/HookInbox.ts";69import * as HookInbox from "./hooks/HookInbox.ts";
70import { HookInboxObject } from "./hooks/HookInboxObject.ts";70import * as HookInboxObject from "./hooks/HookInboxObject.ts";
71import * as HookInboxObjectLayer from "./hooks/HookInboxObject.ts";
7271
73const layerWebcrypto = Layer.succeed(72const layerWebcrypto = Layer.succeed(
74 Crypto.Crypto,73 Crypto.Crypto,
...@@ -201,7 +200,7 @@ export const layer = Api.make(...@@ -201,7 +200,7 @@ export const layer = Api.make(
201 period: HookForwarder.RELAY_HOOK_ENDPOINT_RATE_LIMIT.periodSeconds,200 period: HookForwarder.RELAY_HOOK_ENDPOINT_RATE_LIMIT.periodSeconds,
202 },201 },
203 });202 });
204 const hookInboxes = yield* HookInboxObject;203 const hookInboxes = yield* HookInboxObject.HookInboxObject;
205204
206 //205 //
207 // 3. Runtime layers and app construction206 // 3. Runtime layers and app construction
...@@ -470,7 +469,7 @@ export const layer = Api.make(...@@ -470,7 +469,7 @@ export const layer = Api.make(
470 Layer.provideMerge(Cloudflare.Tunnel.ReadWriteTunnelBinding),469 Layer.provideMerge(Cloudflare.Tunnel.ReadWriteTunnelBinding),
471 Layer.provideMerge(Cloudflare.DNS.ReadWriteDnsHttp),470 Layer.provideMerge(Cloudflare.DNS.ReadWriteDnsHttp),
472 Layer.provideMerge(Cloudflare.Workers.RateLimitBinding),471 Layer.provideMerge(Cloudflare.Workers.RateLimitBinding),
473 Layer.provideMerge(HookInboxObjectLayer.layer),472 Layer.provideMerge(HookInboxObject.layer),
474 // The worker runtime opens its own HTTP span around ours. For webhook473 // The worker runtime opens its own HTTP span around ours. For webhook
475 // paths it would record the raw URL, token included, and adopt the474 // paths it would record the raw URL, token included, and adopt the
476 // sender's traceparent, so only our redacted span covers those.475 // sender's traceparent, so only our redacted span covers those.