warren.storage.publishing_tracker
Publishing tracker: what happened when each document of a job was submitted.
Classes
MongoDBPublishingTracker
classMongoDBPublishingTracker(client, *, database_name, collection_name='job_publishing_results', job_records_ttl_seconds=None, name=None, scoping_enabled=False)Async MongoDB implementation of PublishingTrackerInterface.
Stores publishing outcomes in a job_publishing_results
collection. Success records are keyed by (job_id, doc_id).
Failure records may have doc_id=None if the failure occurred
before a doc_id could be assigned.
Requires calling await setup() after construction to create
indexes.
paramclientAsyncMongoClientparamdatabase_namestrparamcollection_namestr= 'job_publishing_results'paramjob_records_ttl_secondsint | None= NoneTTL on time: a record is deleted this many seconds after its last write. Must be positive. None: the index stays as it is (no TTL by default).
paramnamestr | None= Noneparamscoping_enabledbool= FalseStore the scope of the current handler on each record in a scope field, and index that field.
methodsetupasync () -> NoneCreate indexes for the job_publishing_results collection.
methodrecord_successasync (job_id, doc_id) -> Noneparamjob_idstrparamdoc_idstrmethodrecord_failureasync (job_id, doc_id, source, error, stage) -> Noneparamjob_idstrparamdoc_idstr | Noneparamsourcestrparamerrorstrparamstagestrmethodget_resultsasync (job_id) -> list[dict]paramjob_idstrmethodget_failuresasync (job_id) -> list[dict]paramjob_idstrProtocols
PublishingTrackerInterface
protocolPublishingTrackerInterfaceStorage protocol for publishing outcomes.
methodsetupasync () -> NoneCreate indexes and prepare the store for use.
methodrecord_successasync (job_id, doc_id) -> NoneRecord a successfully published document.
paramjob_idstrparamdoc_idstrmethodrecord_failureasync (job_id, doc_id, source, error, stage) -> NoneRecord a failed publish attempt.
paramjob_idstrparamdoc_idstr | NoneDocument ID, or None if the failure occurred before a doc_id could be assigned.
paramsourcestrHuman-readable source identifier for diagnostics.
paramerrorstrError message describing what went wrong.
paramstagestrWhich step failed: "load", "register", or "publish".
methodget_resultsasync (job_id) -> list[dict]Get all publishing results for a job.
paramjob_idstrReturns
list[dict]List of result records, each containing at least {doc_id, time, success}. Failure records additionally contain {source, error, stage}.
methodget_failuresasync (job_id) -> list[dict]Get only publishing failures for a job.
paramjob_idstrReturns
list[dict]List of failure records (success=False).