Repository navigation
Description
Problem
proTES configures backends in two places (custom.tes.service_list,
custom.tes.discovery with one registry) and merges them with set(),
losing the order. proWES has a hard-coded backend. The default router
needs one ordered, typed list, and the registry trust rules should be
shared by all gateways.
Proposal
foca.plugins.backends:
- Pydantic models for an ordered list of typed entries:
ga4gh-tes(url,url_schemesdefault["https"]so dev/test
setups can allowhttp,id,auth,basicenv var names,labels,
location) and
ga4gh-service-registry(urlhttps only,id,refresh_interval
300,timeout10,versionsas prefixes,environments,authfor
discovered backends,allow_private_addressesfalse);ga4gh-wes
follows with proWES. Unique IDs; URLs normalised (foca.utils.urls),
no user info. Apps put the list under their own key (proTES:
custom.tes.backends). - Registry discovery (moved from proTES, generic by API type): verified
entries only (GET /verifications), type/version/environment filters,
https, public addresses (viafoca.utils.http), no redirects, no
token; cache per entry and process with last-good fallback, retry
≤ 30 s, fork-safe lock. expand(entries, api, public_url): entries in order →Backend
candidates (source,group), own public URL and everything below
it excluded (Q22), de-duplicated byBackend.idat the first
position, configured entry's auth/labels/location winning over
discovered ones;Backend.authset from the entry (registry entries
give theirs to discovered backends). Registries and discovered
backends stayhttpsonly. Snapshot times per registry for provenance.entry_for(backend): the typed entry behind a candidate (credential
type,basicenv var names), so the app attaches credentials after
the forward phase.find(url, refresh=True): look a backend up by URL (normalised), with
a rate-limited registry refresh if unknown, for the Celery tracker and
cancelin other processes (replaces proTES'sget_backend(url)).
Acceptance criteria
- Ordered expansion, de-duplication, configured-wins, self-exclusion,
several registries; discovery filters and trust rules; cache refresh,
last-good list, no list yet → no candidates;url_schemes;
entry_for,findwith refresh rate limit; all without network
(mocked HTTP). - Docs: backend list configuration for apps (with proTES's mapping from
the old keys). - 100% coverage, mypy, ruff,
mkdocs build --strict.
Surviving the Connexion 3 migration
Pydantic models plus the guarded HTTP client; no request context (the
public URL is passed in). Unchanged in rc1; an async refresh can be added
with P8.
Dependencies
- Blocked by feat(utils): add a guarded HTTP client #490 (P5).
- Blocks: feat(plugins): add default failover router #491 (P6).
Open questions
- None.
Added (from the proTES API read): GatewayApp(backends=lambda conf: ...) names the app's backend list config; create_app() validates it and foca.plugins.runtime.get_backend_list() builds the BackendList with the API and server.public_url, so apps don't repeat that glue.
Added during pre-review: malformed /verifications items are skipped and logged; max_stale (default 3600 s, at least refresh_interval) bounds how long a stale registry list is used, after which the entry yields no candidates; registry_allow_private_addresses and registry url_schemes (default [https]) apply to the registry itself, separate from the flag for discovered backends; registry entries require server.public_url (startup error otherwise); the own-URL check compares host, port and path regardless of scheme; foca.plugins.backends is a package (config, registry, lists) with unchanged public imports.
Activity
test(plugins): compare retry times approximately
fix(plugins): address Sourcery review of backends