app.services.poll_trigger¶
Operator-triggered polls (POST /api/v1/sources[/{id}]/poll).
select_poll_targets() validates the request up front (so the HTTP
layer can answer 404/409 before accepting); run_polls() then runs
PollingService to completion. It is
blocking (the polling service makes synchronous database calls) and
is meant to run in a worker thread, e.g. as a FastAPI background task
of a plain def; it starts its own event loop with
asyncio.run().
Concurrency: each registration’s write phase takes the per-registration
advisory lock, so a triggered poll that overlaps a running one (cron,
CLI or another trigger) waits for the lock and then applies its own
consistent result. Progress and outcome are visible through
GET /api/v1/sources (last_attempt_at, last_status).
Public API: select_poll_targets(), run_polls().
- app.services.poll_trigger.run_polls(service, source_ids, trigger)¶
Run the polls to completion (blocking; call from a worker thread).
Errors are logged, never raised: the HTTP response was already sent, and the outcome is recorded on the registration.
- Parameters:
service (
PollingService) – The polling service.source_ids (
Sequence[str]) – Registration ids fromselect_poll_targets().trigger (
JsonValue) – Who triggered the poll (no secrets).
- Return type:
- app.services.poll_trigger.select_poll_targets(config, source_id)¶
Resolve which registrations a poll request covers.
- Parameters:
config (
CatalogConfig) – Loaded configuration.source_id (
str|None) – One registration id, orNonefor all.
- Return type:
- Returns:
Pollable registration ids, in configuration order.
- Raises:
NotFoundError – If source_id is not configured.
ConflictError – If nothing requested can be polled (disabled registration, push-only intake, or no pollable registration at all).