Перенос LogManager в v2 и обновление документации. Обновлены импорты и исправлены ссылки на LogManager в README и тестах. Удалены устаревшие типы и рефакторинг конфигурации управления.
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
# === Раздел с общими конфигурационными параметрами ===
|
||||
runtime: 5
|
||||
|
||||
# === HTTP-канал управления (ConfigManagerV2): /health, /actions/start, /actions/stop ===
|
||||
# management:
|
||||
# enabled: true
|
||||
# host: "0.0.0.0"
|
||||
# port: 8000
|
||||
# timeout: 3
|
||||
# health_timeout: 30
|
||||
|
||||
# === Логирование ===
|
||||
log:
|
||||
version: 1
|
||||
|
||||
@@ -6,7 +6,7 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
from config_manager import ConfigManager
|
||||
from config_manager.v1.log_manager import LogManager
|
||||
from config_manager.v2.core import LogManager
|
||||
from config_manager.v2 import ManagementServerSettings
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
|
||||
from config_manager.v2 import ConfigManagerV2, ManagementServerSettings
|
||||
from config_manager.v2 import ConfigManagerV2
|
||||
|
||||
|
||||
class ReloadApp(ConfigManagerV2):
|
||||
@@ -14,9 +14,9 @@ class ReloadApp(ConfigManagerV2):
|
||||
def test_invalid_config_keeps_last_valid(tmp_path):
|
||||
async def scenario() -> None:
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("log: {}\n", encoding="utf-8")
|
||||
cfg.write_text("log: {}\nmanagement: { enabled: false }\n", encoding="utf-8")
|
||||
|
||||
app = ReloadApp(str(cfg), management_settings=ManagementServerSettings(enabled=False))
|
||||
app = ReloadApp(str(cfg))
|
||||
runner = asyncio.create_task(app.start())
|
||||
|
||||
await asyncio.sleep(0.12)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
|
||||
from config_manager.v2 import ConfigManagerV2, ManagementServerSettings
|
||||
from config_manager.v2 import ConfigManagerV2
|
||||
|
||||
|
||||
class DemoApp(ConfigManagerV2):
|
||||
@@ -18,9 +18,9 @@ class DemoApp(ConfigManagerV2):
|
||||
def test_execute_loop_runs(tmp_path):
|
||||
async def scenario() -> None:
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("log: {}\n", encoding="utf-8")
|
||||
cfg.write_text("log: {}\nmanagement: { enabled: false }\n", encoding="utf-8")
|
||||
|
||||
app = DemoApp(str(cfg), management_settings=ManagementServerSettings(enabled=False))
|
||||
app = DemoApp(str(cfg))
|
||||
runner = asyncio.create_task(app.start())
|
||||
|
||||
await asyncio.sleep(0.18)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
|
||||
from config_manager.v2 import ConfigManagerV2, ManagementServerSettings
|
||||
from config_manager.v2 import ConfigManagerV2
|
||||
from config_manager.v2.control.base import ControlChannel, StartHandler, StatusHandler, StopHandler
|
||||
|
||||
|
||||
@@ -33,14 +33,10 @@ class ControlledApp(ConfigManagerV2):
|
||||
def test_control_channel_can_stop_manager(tmp_path):
|
||||
async def scenario() -> None:
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("log: {}\n", encoding="utf-8")
|
||||
cfg.write_text("log: {}\nmanagement: { enabled: false }\n", encoding="utf-8")
|
||||
|
||||
channel = DummyControlChannel()
|
||||
app = ControlledApp(
|
||||
str(cfg),
|
||||
control_channel=channel,
|
||||
management_settings=ManagementServerSettings(enabled=False),
|
||||
)
|
||||
app = ControlledApp(str(cfg), control_channel=channel)
|
||||
|
||||
runner = asyncio.create_task(app.start())
|
||||
await asyncio.sleep(0.12)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
from config_manager.v2.management import ManagementServer
|
||||
from config_manager.v2.control import HttpControlChannel
|
||||
|
||||
|
||||
def test_health_mapping_ok_to_200():
|
||||
@@ -9,7 +9,7 @@ def test_health_mapping_ok_to_200():
|
||||
return {"status": "ok"}
|
||||
|
||||
async def scenario() -> None:
|
||||
server = ManagementServer(
|
||||
server = HttpControlChannel(
|
||||
host="127.0.0.1",
|
||||
port=8000,
|
||||
timeout=0.2,
|
||||
@@ -27,7 +27,7 @@ def test_health_mapping_unhealthy_to_503():
|
||||
return {"status": "unhealthy", "detail": "worker failed"}
|
||||
|
||||
async def scenario() -> None:
|
||||
server = ManagementServer(
|
||||
server = HttpControlChannel(
|
||||
host="127.0.0.1",
|
||||
port=8000,
|
||||
timeout=0.2,
|
||||
@@ -73,21 +73,21 @@ def test_action_routes_call_callbacks():
|
||||
return status_code, payload
|
||||
|
||||
async def scenario() -> None:
|
||||
server = ManagementServer(
|
||||
channel = HttpControlChannel(
|
||||
host="127.0.0.1",
|
||||
port=0,
|
||||
timeout=0.2,
|
||||
health_provider=provider,
|
||||
)
|
||||
await server.start(on_start, on_stop, on_status)
|
||||
await channel.start(on_start, on_stop, on_status)
|
||||
try:
|
||||
port = server.port
|
||||
port = channel.port
|
||||
assert port > 0
|
||||
|
||||
start_code, start_payload = await request(port, "/actions/start")
|
||||
stop_code, stop_payload = await request(port, "/actions/stop")
|
||||
finally:
|
||||
await server.stop()
|
||||
await channel.stop()
|
||||
|
||||
assert start_code == 200
|
||||
assert start_payload["status"] == "ok"
|
||||
|
||||
@@ -2,7 +2,7 @@ import asyncio
|
||||
import threading
|
||||
import time
|
||||
|
||||
from config_manager.v2 import ConfigManagerV2, ManagementServerSettings
|
||||
from config_manager.v2 import ConfigManagerV2
|
||||
|
||||
|
||||
class BlockingApp(ConfigManagerV2):
|
||||
@@ -26,9 +26,9 @@ class BlockingApp(ConfigManagerV2):
|
||||
def test_stop_waits_for_active_execute_and_prevents_next_run(tmp_path):
|
||||
async def scenario() -> None:
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("log: {}\n", encoding="utf-8")
|
||||
cfg.write_text("log: {}\nmanagement: { enabled: false }\n", encoding="utf-8")
|
||||
|
||||
app = BlockingApp(str(cfg), management_settings=ManagementServerSettings(enabled=False))
|
||||
app = BlockingApp(str(cfg))
|
||||
runner = asyncio.create_task(app.start())
|
||||
|
||||
started = await asyncio.to_thread(app.started_event.wait, 1.0)
|
||||
|
||||
Reference in New Issue
Block a user