This commit is contained in:
2026-03-27 15:51:10 +03:00
parent 15586f9a8c
commit 0bff171936
1245 changed files with 99621 additions and 543076 deletions
@@ -0,0 +1,20 @@
from __future__ import annotations
from collections import defaultdict
from app.modules.agent_api.domain.events.client_event import ClientEventRecord
class ReplayBuffer:
def __init__(self, limit: int = 200) -> None:
self._limit = limit
self._items: dict[str, list[ClientEventRecord]] = defaultdict(list)
def append(self, request_id: str, event: ClientEventRecord) -> None:
history = self._items[request_id]
history.append(event)
if len(history) > self._limit:
del history[: len(history) - self._limit]
def list(self, request_id: str) -> list[ClientEventRecord]:
return list(self._items.get(request_id, []))