Commit bb6fe802 by sunqi02

refactor: ActiveSessionService uses db_factory instead of db instance

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent dea6c941
...@@ -5,7 +5,9 @@ import logging ...@@ -5,7 +5,9 @@ import logging
from dataclasses import dataclass from dataclasses import dataclass
from datetime import datetime from datetime import datetime
from app.infrastructure.time import china_now from app.infrastructure.time import china_now
from typing import Optional from typing import Callable, Optional
from sqlalchemy.orm import Session as SASession
from app.infrastructure.session_store import SessionStore from app.infrastructure.session_store import SessionStore
from app.model.session import Session from app.model.session import Session
...@@ -27,9 +29,9 @@ class ActiveSessionInfo: ...@@ -27,9 +29,9 @@ class ActiveSessionInfo:
class ActiveSessionService: class ActiveSessionService:
def __init__(self, store: Optional[SessionStore] = None, db=None) -> None: def __init__(self, store: Optional[SessionStore] = None, db_factory: Optional[Callable[[], SASession]] = None) -> None:
self.store = store or SessionStore() self.store = store or SessionStore()
self._db = db self._db_factory = db_factory
def get_or_create_session( def get_or_create_session(
self, self,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!