| 12345678910111213141516171819202122232425262728 |
- from __future__ import annotations
- from bom_assistant.scouting.errors import SessionNotFoundError
- from bom_assistant.session.models import BomSession
- class SessionStore:
- def __init__(self) -> None:
- self._sessions: dict[str, BomSession] = {}
- def create(self, session: BomSession) -> None:
- self._sessions[session.session_id] = session
- def get(self, session_id: str) -> BomSession:
- session = self._sessions.get(session_id)
- if session is None:
- raise SessionNotFoundError(session_id)
- return session
- def save(self, session: BomSession) -> None:
- self._sessions[session.session_id] = session
- _store = SessionStore()
- def get_store() -> SessionStore:
- return _store
|