ref #3: [feat] add context and tasks for master-service
This commit is contained in:
parent
f0c4988b44
commit
7b3f82e805
10 changed files with 137 additions and 5 deletions
46
usecase/sandbox.py
Normal file
46
usecase/sandbox.py
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue