Get
Source:
src/Cloudflare/WorkersForPlatforms/Get.ts
Bind a {@link DispatchNamespace} to a Worker and obtain the Effect-native
dynamic-dispatch client (get).
Get is a single identifier that is simultaneously the binding’s Context
tag, its type, and the callable —
yield* Cloudflare.WorkersForPlatforms.Get(namespace).
Provide {@link GetBinding} on the Worker’s runtime layer to resolve the
underlying dispatch_namespace binding at request time.
Dispatching to user Workers
Section titled “Dispatching to user Workers”Bind the namespace during the Worker’s init phase, then look up and forward to a user Worker from a request handler.
const dispatch = yield* Cloudflare.WorkersForPlatforms.Get(namespace);
return { fetch: Effect.gen(function* () { const request = yield* HttpServerRequest; const userWorker = yield* dispatch.get("customer-a"); return yield* Effect.promise(() => userWorker.fetch(request)); }),};