diff --git a/src/central/adapters/nws.py b/src/central/adapters/nws.py index d2ad155..fa12f98 100644 --- a/src/central/adapters/nws.py +++ b/src/central/adapters/nws.py @@ -20,6 +20,7 @@ from tenacity import ( from central import __version__ from central.adapter import SourceAdapter from central.config_models import AdapterConfig, RegionConfig +from central.config_store import ConfigStore from central.models import Event, Geo from shapely.geometry import box as shapely_box, shape as shapely_shape @@ -196,6 +197,7 @@ class NWSAdapter(SourceAdapter): def __init__( self, config: AdapterConfig, + config_store: ConfigStore, cursor_db_path: Path, ) -> None: self.cursor_db_path = cursor_db_path diff --git a/src/central/supervisor.py b/src/central/supervisor.py index beb8f9f..7ce0daf 100644 --- a/src/central/supervisor.py +++ b/src/central/supervisor.py @@ -24,6 +24,12 @@ from central.bootstrap_config import get_settings from central.models import subject_for_event from central.stream_manager import StreamManager +# Adapter registry - add new adapters here +_ADAPTER_REGISTRY: dict[str, type[SourceAdapter]] = { + "nws": NWSAdapter, + "firms": FIRMSAdapter, +} + CURSOR_DB_PATH = Path("/var/lib/central/cursors.db") # Stream subject mappings @@ -152,16 +158,14 @@ class Supervisor: def _create_adapter(self, config: AdapterConfig) -> SourceAdapter: """Create an adapter instance based on config name.""" - if config.name == "nws": - return NWSAdapter(config=config, cursor_db_path=CURSOR_DB_PATH) - elif config.name == "firms": - return FIRMSAdapter( - config=config, - config_store=self._config_store, - cursor_db_path=CURSOR_DB_PATH, - ) - else: + cls = _ADAPTER_REGISTRY.get(config.name) + if cls is None: raise ValueError(f"Unknown adapter type: {config.name}") + return cls( + config=config, + config_store=self._config_store, + cursor_db_path=CURSOR_DB_PATH, + ) async def _run_adapter_loop(self, state: AdapterState) -> None: """Run an adapter poll loop with rate-limit aware scheduling."""