[feat] change str id type to UUID
This commit is contained in:
parent
e629e34c4d
commit
770af1fe76
11 changed files with 150 additions and 173 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import threading
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
from domain.sandbox import SandboxSession
|
||||
from usecase.interface import SandboxSessionRepository
|
||||
|
|
@ -7,10 +8,10 @@ from usecase.interface import SandboxSessionRepository
|
|||
|
||||
class InMemorySandboxSessionRepository(SandboxSessionRepository):
|
||||
def __init__(self) -> None:
|
||||
self._sessions_by_chat_id: dict[str, SandboxSession] = {}
|
||||
self._sessions_by_chat_id: dict[UUID, SandboxSession] = {}
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def get_active_by_chat_id(self, chat_id: str) -> SandboxSession | None:
|
||||
def get_active_by_chat_id(self, chat_id: UUID) -> SandboxSession | None:
|
||||
with self._lock:
|
||||
return self._sessions_by_chat_id.get(chat_id)
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ class InMemorySandboxSessionRepository(SandboxSessionRepository):
|
|||
with self._lock:
|
||||
self._sessions_by_chat_id[session.chat_id] = session
|
||||
|
||||
def delete(self, session_id: str) -> None:
|
||||
def delete(self, session_id: UUID) -> None:
|
||||
with self._lock:
|
||||
for chat_id, session in tuple(self._sessions_by_chat_id.items()):
|
||||
if session.session_id == session_id:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue