Repository navigation
Description
Problem
Gateways need a default route step that is "the least surprising thing
we can imagine". proTES's default today ([[distance, random]]) sends
every task's hosts to third-party geolocation services and loses the
configured order (set()).
Proposal
Built-in plugin foca.routing.ordered (foca.plugins.routing),
registered under the entry-point group foca.plugins by FOCA's own
pyproject.toml, the default route step:
- Input: the expanded, de-duplicated candidates of P10, in the
operator's order. - Keeps the list order and shuffles each registry group in place
(random.SystemRandom); no round-robin state. - Optional params:
labelsfilter (e.g.{"region": "eu-north"});
seedonly if the admin config allows it (tests). - Records the order used per registry group (entry ID, snapshot time,
number of backends, shuffled order) viactx.record(). - Gateway forward rules (in the engine, documented here): not accepted
→ next; when a registry group is exhausted, continue with the next
list entry until the list ends; 5xx or read timeout → outcome unknown,
stop (SYSTEM_ERROR, Q19); totalforward_timeout(60 s) →503
with the attempts' provenance (Q20). - Default pipeline of
PluginsConfigand theappendframe use it, so a
pipeline without a route step still gets routed. - FOCA built-ins are implicitly available: plugins with IDs under
foca.*(e.g.foca.routing.ordered) need noplugins.available
entry; listing one there only setsenabled,rolesand
client_selectable(they can't be uninstalled, so pins don't apply).
Acceptance criteria
- Order kept for configured entries; registry groups shuffled
(statistical test with a fixed seed); labels filter; seed refused
unless allowed; provenance annotations. - Entry point registered and loadable via the same loader path as any
other plugin; usable without anavailableentry;enabled: false
inavailabledisables it (startup error if a required route step is
then left without alternatives). - Docs: routing section (algorithm, failover classification, breaking
change note for proTES). - 100% coverage, mypy, ruff,
mkdocs build --strict.
Surviving the Connexion 3 migration
A plain plugin on the neutral model, without Werkzeug or Flask; becomes
async-capable with P8 without change.
Dependencies
- Blocked by feat(plugins): add plugin engine #486 (P1) and feat(plugins): add typed backend lists #493 (P10).
Open questions
- None.
Added during pre-review: foca.plugins.InvalidParams (a ValueError) is what check_params raises for invalid params (400); any other exception from it is logged and treated as a plugin error; BUILTIN_PLUGINS is the single source of built-in plugins (no entry point in FOCA's metadata), and any other distribution claiming a built-in ID is refused; router labels set in plugins.pipeline don't bind client pipelines (pinning that must always hold belongs in client_pipelines.prepend).
Activity
fix(plugins): address Sourcery review of router