From 306050ad2e56ef7a2e5e162b850583c4e619ccd9 Mon Sep 17 00:00:00 2001 From: Airyland Date: Sat, 28 Nov 2026 22:47:54 -0500 Subject: [PATCH] docs: refine the ctx.exports hook (Rust globals + resolve_entrypoint) The ctxExports object is filled by worker_set_ctx_exports from the Rust-provided globals; the loopback channel is resolved by the Rust resolve_entrypoint. The cache-aware channel wrapper belongs there, not on the v8 object. --- docs/ctx-exports-cache.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/ctx-exports-cache.md b/docs/ctx-exports-cache.md index b340c3e53d7..7bdb65933e1 100644 --- a/docs/ctx-exports-cache.md +++ b/docs/ctx-exports-cache.md @@ -18,11 +18,18 @@ not in front of it. ## Where the hook goes -- `src/workerd/server/factory/worker-factory.c++` builds the `ctxExports` - object after the validator has found the entrypoints (`ctxExportsHandle`). - Each entrypoint is backed by a loopback subrequest channel. Wrap the channel - of every **configured** entrypoint with a cache decorator; leave the rest - untouched. +- `src/workerd/server/factory/worker-factory.c++` creates the `ctxExports` + object, but it is **filled** by `worker_set_ctx_exports`: it compiles the + Rust-provided `spec.globals` (including each `LOOPBACK_SERVICE_STUB` + binding) into the object. Each loopback stub is a numbered subrequest + channel; the channel is resolved by the Rust server's + `resolve_entrypoint`. +- Therefore the decorator belongs where the **channel/global is built** + (Rust `resolve_entrypoint` / the globals construction), not on the v8 + object: wrap the channel of every configured entrypoint with a + cache-aware `IoChannel`/`WorkerInterface`; leave the rest untouched. + The globals only need the entrypoint name and the cache service + designator (the `Worker.entrypointCaches` config). - `src/workerd/server/workerd.capnp`: add to `Worker` ```capnp