Skip to content

feat(plugins): add default failover router #491

Closed

Description

@uniqueg

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: labels filter (e.g. {"region": "eu-north"});
    seed only if the admin config allows it (tests).
  • Records the order used per registry group (entry ID, snapshot time,
    number of backends, shuffled order) via ctx.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); total forward_timeout (60 s) → 503
    with the attempts' provenance (Q20).
  • Default pipeline of PluginsConfig and the append frame 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 no plugins.available
    entry; listing one there only sets enabled, roles and
    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 an available entry; enabled: false
    in available disables 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

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

  1. added this to the v0.18.0 milestone on Oct 24, 2026
  2. added
    priority: high
    status: blocked
    type: feature
    workload: days
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: highstatus: blockedtype: featureworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions