Expand description
A Worker’s binding names must be unique (bynk.context.duplicate_binding).
A Worker’s bindings come from derivations that know nothing of each other:
the KV namespace’s fixed crate::firstparty::KV_BINDING_NAME, a consumed
context’s name (a.b → A_B), an agent’s class name (OrderEntity →
ORDER_ENTITY) and a derived capability’s (Billing →
SERVICE_BILLING). Two of them can meet: an agent Kv in a context that
consumes bynk.cloudflare { Kv } is KV twice, and an agent
ServiceBilling and a capability Billing = Service are both
SERVICE_BILLING. Wrangler takes such a
config without complaint and one binding hides the other, so the clash is
a compile error. The names themselves are never adjusted to avoid it,
because deployed Workers depend on them.
The names are the emitter’s (bynk_emit::emitter::wrangler:: worker_bindings, the list wrangler.toml is written from); this module
owns the check over them and the diagnostic.
Structs§
- Worker
Binding - One binding a Worker declares: the name its
envfield and itswrangler.tomlentry share, and where that name came from.
Enums§
- Binding
Source - What put a binding into a Worker’s
wrangler.toml: the source abynk.context.duplicate_bindingdiagnostic names.
Constants§
- IMPLICIT_
IDEMPOTENCY_ CAPABILITY - W30 (#2840): the
capabilityof theD1Databasesource of a Worker’s implicit idempotency database. Not an identifier, so no project’s own derivedD1capability can carry it: whether a binding is the implicit one is decided by its source, never by its name (a project’scapability Idempotency = D1is bound asD1_IDEMPOTENCYtoo).
Functions§
- duplicate_
bindings - The bindings in
bindingswhose name an earlier one already took, each paired with that earlier one, in list order. - idempotency_
binding - W30 (#2840): the binding of a Worker’s implicit idempotency database, named
IDEMPOTENCY_BINDING. - instance_
binding_ name - S4a (#1966): the Worker binding name of a derived capability, the kind’s
prefix then the capability name in
screaming_snakecase (Sessions→KV_SESSIONS,PriceCache→KV_PRICE_CACHE). - phase_
duplicate_ bindings bynk.context.duplicate_binding: each context’s Worker declares every binding name once.bindingsholds each context’s bindings as itswrangler.tomlwould list them. One error per clash, at the declaration that brought in the second binding (an agent, or aconsumesclause), preferring one the author wrote overconsumes bynk.cloudflare, naming both sources. A clash between two sources with no declaration of their own (Service Bindings added for event subscribers) is reported at the context’s name.- phase_
group_ binding_ collisions bynk.deploy.binding_collision(#3562): the members of a Worker group share onewrangler.tomland oneenv, so a binding name two members both declare is one binding when their declarations are identical (the same kind and options, so the point of co-location is shared state) and an error when they differ.bindingsholds each context’s bindings (phase_duplicate_bindingsreports a name one context repeats). One error per clash, at the later member’s declaration, naming both members and both sources.- screaming_
snake - A declaration’s name in screaming snake case (
OrderEntity→ORDER_ENTITY): the casing of an agent’s binding and of a derived capability’s. One function, so the two kinds of name the duplicate check compares cannot drift apart (review of #1968).