Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /nfraxlab_svc-infra /src /svc_infra /data /erasure.py
| from __future__ import annotations | |
| from collections.abc import Awaitable, Callable, Iterable | |
| from dataclasses import dataclass | |
| from typing import Any, Protocol | |
| class SqlSession(Protocol): # minimal protocol for tests/integration | |
| async def execute(self, stmt: Any) -> Any: | |
| pass | |
| class ErasureStep: | |
| name: str | |
| run: Callable[[SqlSession, str], Awaitable[int] | int] | |
| class ErasurePlan: | |
| steps: Iterable[ErasureStep] | |
| async def run_erasure( | |
| session: SqlSession, | |
| principal_id: str, | |
| plan: ErasurePlan, | |
| *, | |
| on_audit: Callable[[str, dict[str, Any]], None] | None = None, | |
| ) -> int: | |
| """Run an erasure plan and optionally emit an audit event. | |
| Returns total affected rows across steps. | |
| """ | |
| total = 0 | |
| for s in plan.steps: | |
| res = s.run(session, principal_id) | |
| if hasattr(res, "__await__"): | |
| res = await res | |
| total += int(res or 0) | |
| if on_audit: | |
| on_audit("erasure.completed", {"principal_id": principal_id, "affected": total}) | |
| return total | |
| __all__ = ["ErasureStep", "ErasurePlan", "run_erasure"] | |
Xet Storage Details
- Size:
- 1.15 kB
- Xet hash:
- 486efa7d54918a74323ef8649ea9dc93476f55ecfa5a1374e209147aacd76b58
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.