重构模型平台前后端并移除Redis依赖
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Protocol
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class EnsureRuntimeRequest:
|
||||
runtime_id: str
|
||||
workspace_id: str
|
||||
workspace_code: str
|
||||
owner_user_id: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RuntimeEndpoint:
|
||||
runtime_id: str
|
||||
runtime_type: str
|
||||
provider: str
|
||||
runtime_ref: str
|
||||
internal_url: str
|
||||
proxy_base_path: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RuntimeHealth:
|
||||
runtime_id: str
|
||||
healthy: bool
|
||||
checked_at: datetime
|
||||
detail: str | None = None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CreateSessionRequest:
|
||||
runtime_id: str
|
||||
workspace_code: str
|
||||
relative_path: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RuntimeSession:
|
||||
runtime_id: str
|
||||
session_id: str
|
||||
jupyter_url: str
|
||||
reused: bool
|
||||
|
||||
|
||||
class RuntimeAdapter(Protocol):
|
||||
async def ensure_running(
|
||||
self,
|
||||
request: EnsureRuntimeRequest,
|
||||
) -> RuntimeEndpoint: ...
|
||||
|
||||
async def stop(self, runtime_id: str, reason: str) -> None: ...
|
||||
|
||||
async def restart(self, runtime_id: str) -> RuntimeEndpoint: ...
|
||||
|
||||
async def health(self, runtime_id: str) -> RuntimeHealth: ...
|
||||
|
||||
async def create_session(
|
||||
self,
|
||||
request: CreateSessionRequest,
|
||||
) -> RuntimeSession: ...
|
||||
|
||||
async def terminate_session(
|
||||
self,
|
||||
runtime_id: str,
|
||||
session_id: str,
|
||||
) -> None: ...
|
||||
Reference in New Issue
Block a user