rename Test file and add init file for metric backend to import all at once

This commit is contained in:
2026-04-04 22:26:19 +02:00
parent 043d7654f9
commit 2b8f0396e3
4 changed files with 14 additions and 6 deletions
+8 -2
View File
@@ -1,13 +1,19 @@
from typing import Any, Awaitable, cast
import inspect, os
import inspect, time, os
class StoreTemplate:
def __init__(self, backend:str="memory", key_prefix:str="snake:metrics:worker", worker_id:str|None=None, **kwargs):
self.backend = (backend or "memory").strip().lower()
self.key_prefix = key_prefix
self.worker_id = worker_id or f"{os.getpid()}"
self.worker_id = worker_id or f"{os.getpid()}-{int(time.time() * 1000)}"
self.store = self
async def publish(self, worker_id:str, snapshot:dict) -> None:
raise NotImplementedError
async def load_all(self) -> list[dict]:
raise NotImplementedError
async def publish_only(self, snapshot:dict) -> None:
await self.store.publish(self.worker_id, snapshot)