Добавлена возможность регистрировать прикладные апи
This commit is contained in:
@@ -13,6 +13,7 @@ from app_runtime.core.registration import ModuleRegistry
|
||||
from app_runtime.core.service_container import ServiceContainer
|
||||
from app_runtime.core.types import HealthPayload, LifecycleState
|
||||
from app_runtime.health.registry import HealthRegistry
|
||||
from app_runtime.http.service import ApplicationHttpService
|
||||
from app_runtime.logging.manager import LogManager
|
||||
from app_runtime.tracing.reader import build_trace_log_reader
|
||||
from app_runtime.tracing.service import TraceService
|
||||
@@ -32,6 +33,7 @@ class RuntimeManager:
|
||||
logs: LogManager | None = None,
|
||||
workers: WorkerSupervisor | None = None,
|
||||
control_plane: ControlPlaneService | None = None,
|
||||
application_http: ApplicationHttpService | None = None,
|
||||
) -> None:
|
||||
self.configuration = configuration or ConfigurationManager()
|
||||
self.services = services or ServiceContainer()
|
||||
@@ -40,6 +42,7 @@ class RuntimeManager:
|
||||
self.logs = logs or LogManager()
|
||||
self.workers = workers or WorkerSupervisor()
|
||||
self.control_plane = control_plane or ControlPlaneService()
|
||||
self.application_http = application_http or ApplicationHttpService()
|
||||
self.registry = ModuleRegistry(self.services)
|
||||
self._started = False
|
||||
self._state = LifecycleState.IDLE
|
||||
@@ -67,6 +70,8 @@ class RuntimeManager:
|
||||
self.workers.start()
|
||||
if start_control_plane:
|
||||
self.control_plane.start(self)
|
||||
self._register_application_http_routes()
|
||||
self.application_http.start(self)
|
||||
self._started = True
|
||||
self._refresh_state()
|
||||
|
||||
@@ -75,6 +80,7 @@ class RuntimeManager:
|
||||
return
|
||||
self._state = LifecycleState.STOPPING
|
||||
self.workers.stop(timeout=timeout, force=force)
|
||||
self.application_http.stop()
|
||||
if stop_control_plane:
|
||||
self.control_plane.stop()
|
||||
self._started = False
|
||||
@@ -120,6 +126,7 @@ class RuntimeManager:
|
||||
except TimeoutError:
|
||||
return self._action_detail("runtime stop is still in progress", timed_out=True)
|
||||
|
||||
self.application_http.stop()
|
||||
self._refresh_state()
|
||||
if self._state == LifecycleState.STOPPED:
|
||||
self._started = False
|
||||
@@ -148,6 +155,7 @@ class RuntimeManager:
|
||||
self.services.register("logs", self.logs)
|
||||
self.services.register("workers", self.workers)
|
||||
self.services.register("control_plane", self.control_plane)
|
||||
self.services.register("application_http", self.application_http)
|
||||
self._core_registered = True
|
||||
|
||||
def _register_health_contributors(self) -> None:
|
||||
@@ -161,6 +169,11 @@ class RuntimeManager:
|
||||
self.workers.register(worker)
|
||||
self._workers_registered = True
|
||||
|
||||
def _register_application_http_routes(self) -> None:
|
||||
for registrar in self.registry.http_route_registrars:
|
||||
self.application_http.register_routes(registrar)
|
||||
self.registry.http_route_registrars.clear()
|
||||
|
||||
def _refresh_state(self) -> None:
|
||||
lifecycle = self.workers.lifecycle_state()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user