Skip to main content

Module worker_groups

Module worker_groups 

Source
Expand description

#3562 (slice G1): the Worker groups of bynk.toml.

Under the workers target a context is one Worker. A group puts several contexts in one Worker, so a handful of contexts that belong together need not each cost a Worker and a network hop:

[deploy.workers.core]
contexts = ["shop.orders", "shop.catalogue", "shop.pricing"]

[deploy.workers.payments]
contexts = ["shop.payment"]
name = "acme-payments"          # the Cloudflare script name; default is the key
routes = ["pay.example.com/*"]

The key is the group’s identity (its ledger entry, its --worker selector, its workers/<key>/ directory); name only overrides the script’s name on Cloudflare. A context named in no group stays one Worker under its dashed name, so a project with no [deploy.workers] is unchanged.

This module reads the table and checks everything that needs no project model: shapes, the grammar of names, a context in two groups, two groups sharing a script name, a route or domain claimed twice. What needs the project’s contexts (an unknown context, a context that is not deployable, a key that collides with an implicit Worker’s name) is checked against them by validate_against.

Structs§

GroupIssue
A rule the groups break against the project’s contexts.
ProjectUnits
The units of a project, by kind, as validate_against needs them.
WorkerGroup
One group’s [deploy.workers.<key>] entry.

Constants§

GROUP_KEYS
The keys of a [deploy.workers.<key>] entry.

Functions§

deploy_workers_from
The [deploy] table’s workers entries.
is_qualified_name
Whether name is a qualified context name: dot-separated segments, each an identifier (letters, digits and _, not starting with a digit).
is_worker_name
Whether name can be a Worker’s key or script name: Cloudflare’s own grammar, 1 to 63 lowercase letters, digits and -, not starting or ending with one. It becomes a directory, a command-line argument and a ledger key, so nothing else may reach them.
try_read_worker_groups
try_read_worker_groups_with, reading bynk.toml from disk.
try_read_worker_groups_with
Read bynk.toml’s [deploy.workers] groups, honouring overlay (an open, unsaved buffer) and otherwise reading the manifest from disk, as read_package_config does. No manifest, or none of the table, is empty.
validate_against
Check groups against the project’s units: every member exists and is a context, and no group’s key or script name is an implicit Worker’s (a context in no group is a Worker named by its dashed name).

Type Aliases§

WorkerGroups
The [deploy.workers] groups, by key.