diff --git a/klimalogger/store/__init__.py b/klimalogger/store/__init__.py index b11964b..2f69e89 100644 --- a/klimalogger/store/__init__.py +++ b/klimalogger/store/__init__.py @@ -7,6 +7,14 @@ log = logging.getLogger(__name__) +def influxdb_store_factory(config: Config): + if config.store_org is not None: + from .influxdb2 import InfluxDbStore + return InfluxDbStore(config) + else: + from .influxdb import InfluxDbStore + return InfluxDbStore(config) + class StoreModule(Module): @provider @singleton @@ -16,9 +24,5 @@ def store_provider(self, config: Config) -> StoreClient: if config.store_type == 'queue': from .queue import CombinedStore return CombinedStore(config) - elif config.store_org is not None: - from .influxdb2 import InfluxDbStore - return InfluxDbStore(config) else: - from .influxdb import InfluxDbStore - return InfluxDbStore(config) + return influxdb_store_factory(config) diff --git a/klimalogger/store/queue.py b/klimalogger/store/queue.py index 61f13d1..46179ed 100644 --- a/klimalogger/store/queue.py +++ b/klimalogger/store/queue.py @@ -5,8 +5,8 @@ from injector import inject from paho.mqtt import client as mqtt_client +from . import influxdb_store_factory from .client import StoreClient -from .influxdb import InfluxDbStore from .. import config log = logging.getLogger(__name__) @@ -18,7 +18,7 @@ class CombinedStore(StoreClient): def __init__(self, configuration: config.Config): log.info("create combined store") self.stores = [ - InfluxDbStore(configuration), + influxdb_store_factory(configuration), QueueStore(configuration) ] diff --git a/pyproject.toml b/pyproject.toml index 640580f..7fd7f67 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "klimalogger" -version = "0.6.9" +version = "0.6.10" authors = [ { name = "Andreas Würl", email = "andi@tryb.de" }, ]