app.services.poll_plan¶
Value types and pure planning steps of a poll run.
Used by app.services.polling: PollPlan collects what a
run found (counters, problems, documents to write, tokens to refresh,
rows to delete); plan_project() applies the ownership rule, skips
unchanged documents and plans deletions for one project listing;
bounded() runs adapter calls with bounded concurrency.
Public API: PollProblem, PollCounts,
PollOutcome, PollPlan, StoredState,
bounded(), plan_project().
- class app.services.poll_plan.PollProblem(*, code, message, project=None, path=None)¶
Bases:
objectOne finding of a poll run.
- class app.services.poll_plan.PollCounts(projects=0, documents=0, unchanged=0, fetched=0, created=0, updated=0, same_content=0, tokens_refreshed=0, deleted=0, skipped_owned=0, failed=0)¶
Bases:
objectCounters of one poll run.
- Parameters:
projects (
int) – Projects listed.documents (
int) – Documents listed and owned by the registration.unchanged (
int) – Documents skipped without fetching.fetched (
int) – Documents fetched.created (
int) – New published rows.updated (
int) – Rows whose digest changed.same_content (
int) – Fetched rows whose digest did not change.tokens_refreshed (
int) – Unchanged rows whose change token moved.deleted (
int) – Published rows removed by reconciliation.skipped_owned (
int) – Files skipped (owned by an earlier registration).failed (
int) – Listings or fetches that failed.
- class app.services.poll_plan.PollOutcome(*, source_id, status, run_id, counts, problems)¶
Bases:
objectResult of polling one registration.
- Parameters:
source_id (
str) – Registration id.status (
PollStatus) – Outcome (disabledwhen not pollable).run_id (
UUID|None) – Intake run id (Nonewhen nothing ran).counts (
PollCounts) – Counters.problems (
tuple[PollProblem,...]) – Findings.
- status: PollStatus¶
- counts: PollCounts¶
- problems: tuple[PollProblem, ...]¶
- class app.services.poll_plan.PollPlan(counts=PollCounts(), problems=list(), complete=True, prepared=list(), refresh=list(), delete=list())¶
Bases:
objectEverything collected for one registration, applied under lock.
- Parameters:
counts (
PollCounts) – Counters.problems (
list[PollProblem]) – Findings.complete (
bool) –Falseonce anything was incomplete or failed.prepared (
list[PreparedDocument]) – Fetched documents to ingest.refresh (
list[tuple[UUID,str|None]]) –(record id, new token)of unchanged documents.
- counts: PollCounts¶
- problems: list[PollProblem]¶
- prepared: list[PreparedDocument]¶
- fail(problem)¶
Record a problem that makes the run partial.
- Parameters:
problem (
PollProblem) – The problem.- Return type:
- class app.services.poll_plan.StoredState(own, owned_elsewhere)¶
Bases:
objectStored state read before collecting.
- Parameters:
- async app.services.poll_plan.bounded[T](limit, jobs)¶
Run coroutine factories with bounded concurrency, keeping order.
- app.services.poll_plan.plan_project(project, listing, stored, plan)¶
Apply ownership, skip unchanged and plan deletions of a project.
- Parameters:
project (
SourceProject) – The project.listing (
DocumentListing) – Its document listing.stored (
StoredState) – Stored state.plan (
PollPlan) – Plan to fill.
- Return type:
- Returns:
Documents to fetch.