Skip to main content

Module wrangler

Module wrangler 

Source
Expand description

wrangler.toml generation per Worker (v0.8 §4.4 / §4.5).

Each context becomes a Cloudflare Worker with its own wrangler config. Service Bindings are declared for every consumed context. Durable Object bindings + exports entries are declared for every agent.

Constants§

COMPATIBILITY_DATE
Compile-time pinned compatibility date. Cloudflare uses this to lock Workers runtime behaviour. When to bump it, and the gate a bump must pass, is the policy in design/bynk-release-discipline.md (“Part 3 — The Workers compatibility date”, #1677): reviewed at each release, and moved only after the workerd smokes pass on the new date.
DEFAULT_COMPATIBILITY_FLAGS
#1890: the compatibility flags every emitted Worker carries, ahead of the project’s own (bynk.toml’s [workers] compatibility_flags).
EVENTS_FANOUT_CLASS_NAME
Events track, slice 0 (spine #936, ADR 0284): the class name of a publishing context’s fan-out Durable Object (emitter::events_fanout). Shared with emitter::workers (the Env field name + deps. __eventsDispatch call it drives) and emitter::events_fanout (the class this name must actually export) so the three can never drift apart.
FOREIGN_SERVICE_DOUBLE_STATUS
Interop I5 (#1972): the status of the stand-in for a foreign Worker that bynk dev binds by default and the integration test harness binds always. 503, not a 2xx: the stand-in served nothing, and code that ignores the status should not mistake it for the Worker’s answer.
KV_BINDING_NAME
The bare Kv’s binding (KV), re-exported for bynk deploy, which reads generated configs and tells the bare namespace from derived instances by it (S4b, #1967). The fixed Worker binding name for the Kv namespace (decision C1, v0.19): one namespace, one [[kv_namespaces]] stanza, one env.KV field.
KV_NAMESPACE_ID_PLACEHOLDER
Deploy-time sentinel in generated Worker configuration. The driver replaces this with the persistent Cloudflare KV namespace id immediately before a remote Wrangler command runs.
WRANGLER_MIN
#1732: the oldest wrangler whose bundled workerd serves COMPATIBILITY_DATE. An older workerd refuses a newer date outright (wrangler dev exits: “This Worker requires compatibility date …”), so bynk doctor warns about a wrangler below this. Set by the same compatibility-date review that sets the date (Part 3’s lag rule keeps it at least three months old). bynk-emit/tests/compat_date_policy.rs checks the policy doc names both.

Functions§

compatibility_flags
#1890: the flags a Worker’s wrangler.toml carries, and the duplicates dropped on the way. DEFAULT_COMPATIBILITY_FLAGS come first, then extra (the manifest’s list) in order. A name already present, whether a default or earlier in extra, is dropped and returned in the second list, once per extra occurrence, for the caller to warn about. Names are not otherwise checked.
foreign_service_double_body
Interop I5 (#1972): the body of that stand-in’s every response, saying what it is. bynk dev adds how to reach the real Worker instead.
kv_bindings_needing_ids
The bindings of a generated wrangler.toml’s [[kv_namespaces]] entries whose id is still that binding’s deploy-time placeholder (kv_id_placeholder), in file order: what materialise_kv_namespace_ids would patch. Exposed so a caller can learn which ids it needs before doing the (possibly fallible) work of finding them, as bynk dev --remote does before it reads the ledger. Empty for a config with no KV, or one already materialised.
kv_id_placeholder
The deploy-time placeholder a [[kv_namespaces]] entry for binding carries until bynk deploy materialises it: KV_NAMESPACE_ID_PLACEHOLDER for the bare KV, kv_instance_id_placeholder for a derived instance (S4b, #1967).
kv_instance_id_placeholder
S4a (#1966): the deploy-time id placeholder of a derived KV instance’s [[kv_namespaces]] entry: KV_SESSIONS → <KV_SESSIONS_ID>.
kv_instance_title
S4b (#1967): the account-facing title stem of a derived instance’s KV namespace, <worker>-<capability, kebab>: shop-cart and KV_SESSIONS give shop-cart-sessions, KV_PRICE_CACHE gives shop-cart-price-cache. Read off the binding, which is a function of the capability’s name, so a renamed capability is a new title. bynk deploy environment-qualifies it.
materialise_kv_namespace_ids
Materialise deploy-time KV namespace ids in a generated wrangler.toml’s text, structurally, by binding (S4b, #1967). Each [[kv_namespaces]] entry whose binding has an id in ids, and whose id is currently exactly that binding’s placeholder (kv_id_placeholder), gets the id; the decor around the value (the # set at deploy time note) is kept.
materialise_r2_bucket_names
P5 (#2323): point [[r2_buckets]] entries at their deploy-time bucket names, structurally, by binding: each entry whose binding names lists gets that bucket_name. The generated name is the unqualified derived one (r2_bucket_name); an environment qualifies it. Unchanged text when nothing differs, as materialise_kv_namespace_ids.
materialise_ratelimit_namespace_ids
P3 (#2342): write each rate limiter’s allocated namespace_id over its placeholder, structurally, by name, leaving its simple = { … } and comment as they are. Unchanged text when nothing matches, as materialise_kv_namespace_ids.
r2_bucket_entries
A generated wrangler.toml’s [[r2_buckets]] entries as (binding, bucket_name, jurisdiction), in file order; an entry missing a binding or a name is skipped.
r2_bucket_name
P5 (#2323): the account-facing name of an R2 instance’s bucket, <worker>-<capability, kebab>: shop-cart and R2_ARCHIVES give shop-cart-archives. R2 bucket names are scoped to the account (not the Worker), so the Worker’s name carries the uniqueness. bynk deploy environment-qualifies it.
ratelimit_namespace_placeholder
P3 (#2342): the placeholder namespace_id of rate limiter binding, which bynk deploy replaces with the id the ledger allocates. Miniflare takes it as it is, so bynk dev runs with it.
ratelimits_needing_ids
P3 (#2342): the rate limiters whose namespace_id is still its placeholder, by name, in file order.
retarget_services
Interop I5 (#1972): point Service Bindings at other Workers, structurally, by binding: each [[services]] entry whose binding targets names gets that service. bynk dev uses it to bind a foreign Worker to its local stand-in, which runs under a name of its own so that it never answers for the real Worker in wrangler’s shared dev registry. Unchanged text when nothing matches, as materialise_kv_namespace_ids.