rename Test file and add init file for metric backend to import all at once
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user