mirror of
https://github.com/zvx-echo6/central.git
synced 2026-05-21 18:14:44 +02:00
refactor: supervisor always uses DbConfigSource
Remove conditional config source loading, simplify async_main. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a1e81bae8a
commit
c6f4f3b081
2 changed files with 12 additions and 27 deletions
|
|
@ -308,7 +308,7 @@ async def async_main() -> None:
|
||||||
"Archive starting",
|
"Archive starting",
|
||||||
extra={
|
extra={
|
||||||
"nats_url": settings.nats_url,
|
"nats_url": settings.nats_url,
|
||||||
"config_source": settings.config_source,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ from nats.js import JetStreamContext
|
||||||
|
|
||||||
from central.adapters.nws import NWSAdapter
|
from central.adapters.nws import NWSAdapter
|
||||||
from central.cloudevents_wire import wrap_event
|
from central.cloudevents_wire import wrap_event
|
||||||
from central.config import load_config, Config, NWSAdapterConfig
|
from central.config import NWSAdapterConfig
|
||||||
from central.config_models import AdapterConfig
|
from central.config_models import AdapterConfig
|
||||||
from central.config_source import ConfigSource, create_config_source
|
from central.config_source import ConfigSource, DbConfigSource
|
||||||
from central.bootstrap_config import get_settings
|
from central.bootstrap_config import get_settings
|
||||||
from central.models import subject_for_event
|
from central.models import subject_for_event
|
||||||
|
|
||||||
|
|
@ -528,7 +528,7 @@ class Supervisor:
|
||||||
for config in enabled_adapters:
|
for config in enabled_adapters:
|
||||||
await self._start_adapter(config)
|
await self._start_adapter(config)
|
||||||
|
|
||||||
# Start config watcher (for DB source, this runs forever; for TOML, returns immediately)
|
# Start config watcher (runs forever, calling callback on changes)
|
||||||
self._config_watch_task = asyncio.create_task(
|
self._config_watch_task = asyncio.create_task(
|
||||||
self._config_source.watch_for_changes(self._on_config_change)
|
self._config_source.watch_for_changes(self._on_config_change)
|
||||||
)
|
)
|
||||||
|
|
@ -579,37 +579,22 @@ async def async_main() -> None:
|
||||||
|
|
||||||
settings = get_settings()
|
settings = get_settings()
|
||||||
logger.info(
|
logger.info(
|
||||||
"Config source: %s",
|
"Config source: db",
|
||||||
settings.config_source,
|
extra={"config_source": "db"},
|
||||||
extra={"config_source": settings.config_source},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create config source based on setting
|
# Create database config source
|
||||||
config_source = await create_config_source(
|
config_source = await DbConfigSource.create(settings.db_dsn)
|
||||||
source_type=settings.config_source,
|
|
||||||
dsn=settings.db_dsn,
|
|
||||||
toml_path=settings.config_toml_path,
|
|
||||||
)
|
|
||||||
|
|
||||||
# CloudEvents config: try TOML first, fall back to code defaults
|
|
||||||
# (CloudEvents envelope format is protocol-level, not operator-configurable)
|
|
||||||
cloudevents_config = None
|
|
||||||
if settings.config_source == "toml":
|
|
||||||
try:
|
|
||||||
toml_config = load_config(str(settings.config_toml_path))
|
|
||||||
cloudevents_config = toml_config
|
|
||||||
except Exception:
|
|
||||||
pass # Will use defaults from cloudevents_constants
|
|
||||||
|
|
||||||
supervisor = Supervisor(
|
supervisor = Supervisor(
|
||||||
config_source=config_source,
|
config_source=config_source,
|
||||||
nats_url=settings.nats_url,
|
nats_url=settings.nats_url,
|
||||||
cloudevents_config=cloudevents_config,
|
# CloudEvents uses protocol-level defaults from cloudevents_constants
|
||||||
|
cloudevents_config=None,
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
"CloudEvents config: %s",
|
"CloudEvents config: defaults",
|
||||||
"TOML" if cloudevents_config else "defaults",
|
extra={"cloudevents_source": "defaults"},
|
||||||
extra={"cloudevents_source": "toml" if cloudevents_config else "defaults"},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue