From 1ea56b67fd6041512e686d115bd74a864708f523 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Sat, 16 May 2026 18:49:40 +0000 Subject: [PATCH] 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 --- src/central/adapter.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/central/adapter.py b/src/central/adapter.py index a701558..2037eef 100644 --- a/src/central/adapter.py +++ b/src/central/adapter.py @@ -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