refactor(adapter): add abstract apply_config method

SourceAdapter now requires apply_config() for hot-reload support.
Each adapter implements its own config extraction from settings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson 2026-05-16 18:49:40 +00:00
commit 1ea56b67fd

View file

@ -2,6 +2,10 @@
from abc import ABC, abstractmethod
from collections.abc import AsyncIterator
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from central.config_models import AdapterConfig
from central.models import Event
@ -15,7 +19,6 @@ class SourceAdapter(ABC):
"""
name: str # short identifier, e.g. "nws"
cadence_s: int # seconds between poll() calls
@abstractmethod
async def poll(self) -> AsyncIterator[Event]:
@ -26,6 +29,17 @@ class SourceAdapter(ABC):
"""
...
@abstractmethod
async def apply_config(self, new_config: "AdapterConfig") -> None:
"""
Apply new configuration to the adapter.
Called by supervisor when config changes via hot-reload.
The adapter should extract relevant settings from
new_config.settings and update its internal state.
"""
...
async def startup(self) -> None:
"""Optional lifecycle hook called before first poll."""
pass