ref #3: [feat] add context and tasks for master-service

This commit is contained in:
Azamat 2026-04-02 12:04:47 +03:00
parent f0c4988b44
commit 7b3f82e805
10 changed files with 137 additions and 5 deletions

46
usecase/sandbox.py Normal file
View file

@ -0,0 +1,46 @@
from dataclasses import dataclass
from datetime import timedelta
from domain.sandbox import SandboxSession
from usecase.interface import Clock, Logger, SandboxRuntime, SandboxSessionRepository
@dataclass(frozen=True, slots=True)
class CreateSandboxCommand:
chat_id: str
class CreateSandbox:
def __init__(
self,
repository: SandboxSessionRepository,
runtime: SandboxRuntime,
clock: Clock,
logger: Logger,
ttl: timedelta,
) -> None:
self._repository = repository
self._runtime = runtime
self._clock = clock
self._logger = logger
self._ttl = ttl
def execute(self, command: CreateSandboxCommand) -> SandboxSession:
raise NotImplementedError
class CleanupExpiredSandboxes:
def __init__(
self,
repository: SandboxSessionRepository,
runtime: SandboxRuntime,
clock: Clock,
logger: Logger,
) -> None:
self._repository = repository
self._runtime = runtime
self._clock = clock
self._logger = logger
def execute(self) -> list[SandboxSession]:
raise NotImplementedError