This commit is contained in:
2026-07-23 01:15:04 +02:00
parent 582e37d176
commit b534a496fd
79 changed files with 4086 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
# retoor <retoor@molodetz.nl>
from dataclasses import dataclass, field
import threading
@dataclass
class RequestCounters:
requests: int = 0
errors: int = 0
_lock: threading.Lock = field(default_factory=threading.Lock, repr=False)
def record_request(self) -> None:
with self._lock:
self.requests += 1
def record_error(self) -> None:
with self._lock:
self.errors += 1
def snapshot(self) -> dict[str, int]:
with self._lock:
return {"requests": self.requests, "errors": self.errors}
COUNTERS = RequestCounters()