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

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Opus 5.5 authored and GitHub committed 2026-10-05 19:30:02 -07:00
1 parent 31d0c8a4f4
commit 8bd7745f0a
2 files changed
+10 -13

No files matched your search

+7 -9
View File
@@ -23,14 +23,6 @@ const RUN_FAILURE_RETRY_MS = 60_000;
type Call<A> = Effect.Effect<A, never, Alchemy.RuntimeContext>;
export interface HookInboxObjectShape {
/** Holds a request for `baseUrl`; false when the inbox is full and nothing was stored. */
readonly hold: (hook: HookInboxStore.HeldHook, baseUrl: string) => Call<boolean>;
/** The environment is back at `baseUrl`: deliver what is waiting now. */
readonly wake: (baseUrl: string) => Call<boolean>;
readonly clear: () => Call<void>;
}
/**
* One per managed endpoint, addressed by endpoint key. Holds webhook requests
* the environment could not take, in SQLite, and pushes them back through
@@ -38,7 +30,13 @@ export interface HookInboxObjectShape {
*/
export class HookInboxObject extends Cloudflare.DurableObject<
HookInboxObject,
HookInboxObjectShape
{
/** Holds a request for `baseUrl`; false when the inbox is full and nothing was stored. */
readonly hold: (hook: HookInboxStore.HeldHook, baseUrl: string) => Call<boolean>;
/** The environment is back at `baseUrl`: deliver what is waiting now. */
readonly wake: (baseUrl: string) => Call<boolean>;
readonly clear: () => Call<void>;
}
>()("HookInboxObject") {}
/**
+3 -4
View File
@@ -67,8 +67,7 @@ import * as MobileRegistrations from "./agentActivity/MobileRegistrations.ts";
import * as HookForwarder from "./hooks/HookForwarder.ts";
import * as HeldHooks from "./hooks/HeldHooks.ts";
import * as HookInbox from "./hooks/HookInbox.ts";
import { HookInboxObject } from "./hooks/HookInboxObject.ts";
import * as HookInboxObjectLayer from "./hooks/HookInboxObject.ts";
import * as HookInboxObject from "./hooks/HookInboxObject.ts";
const layerWebcrypto = Layer.succeed(
Crypto.Crypto,
@@ -201,7 +200,7 @@ export const layer = Api.make(
period: HookForwarder.RELAY_HOOK_ENDPOINT_RATE_LIMIT.periodSeconds,
},
});
const hookInboxes = yield* HookInboxObject;
const hookInboxes = yield* HookInboxObject.HookInboxObject;
//
// 3. Runtime layers and app construction
@@ -470,7 +469,7 @@ export const layer = Api.make(
Layer.provideMerge(Cloudflare.Tunnel.ReadWriteTunnelBinding),
Layer.provideMerge(Cloudflare.DNS.ReadWriteDnsHttp),
Layer.provideMerge(Cloudflare.Workers.RateLimitBinding),
Layer.provideMerge(HookInboxObjectLayer.layer),
Layer.provideMerge(HookInboxObject.layer),
// The worker runtime opens its own HTTP span around ours. For webhook
// paths it would record the raw URL, token included, and adopt the
// sender's traceparent, so only our redacted span covers those.