harp_apps.janitor.worker¶
- class JanitorWorker[source]¶
Bases:
object
- __init__(storage, blob_storage)[source]¶
- Parameters:
storage (IStorage)
blob_storage (IBlobStorage)
- async compute_and_store_metrics(*, session)[source]¶
Compute counts of objects in storage, and store them as metrics.
- async delete_old_transactions(*, session)[source]¶
Remove transactions older than OLD_AFTER days. On correct database implementations (postgresql for example), it will cascade to related objects. On sqlite, there will be garbage left, but it’s not a big deal.
- async delete_orphan_blobs(*, session)[source]¶
Find and remove blobs that are not referenced anymore by any transaction.
- async do_count(session, name, /, *, method='count')[source]¶
Helper to count objects in storage, from different repositories and using different methods for building the actual query.
- Parameters:
session – sqlalchemy async session
name (str) – repository name (should be available from storage)
method – method name to call on the repository to get the actual sqlalchemy query, default as “count”
- Returns:
integer