rename module

This commit is contained in:
2026-01-06 23:28:08 +03:00
parent 09ff5c4ec4
commit 75c7601df9
3 changed files with 16 additions and 16 deletions

View File

@@ -22,6 +22,11 @@ try:
INFLUXDB_AVAILABLE = True
except ImportError:
INFLUXDB_AVAILABLE = False
InfluxClient = None
Point = None
WritePrecision = None
SYNCHRONOUS = None
ASYNCHRONOUS = None
logger.warning("influxdb-client not installed. Install with: pip install influxdb-client")
@@ -45,28 +50,23 @@ class InfluxDBClient:
if hasattr(self, '_initialized'):
return
if not INFLUXDB_AVAILABLE:
self.logger = logger
self.client = None
self.write_api = None
self._initialized = False
self.logger.error("InfluxDB client library not available")
return
self.config = config.influxdb
self.logger = logger
# Инициализируем атрибуты по умолчанию
self.client: Optional[InfluxClient] = None
self.write_api = None
# Очередь для пакетной отправки
self.message_queue: Queue[Dict[str, Any]] = Queue()
self.running = False
self.forwarder_thread: Optional[threading.Thread] = None
# Статистика
self.sent_count = 0
self.failed_count = 0
self.retry_count = 0
self._initialized = False
if not INFLUXDB_AVAILABLE:
self.logger.error("InfluxDB client library not available")
return
# Инициализируем клиент
self._init_client()
@@ -255,7 +255,7 @@ class InfluxDBClient:
if not self.config.enabled or not self.write_api:
return
if self.running:
if hasattr(self, 'running') and self.running:
self.logger.warning("InfluxDB forwarder is already running")
return
@@ -270,7 +270,7 @@ class InfluxDBClient:
def stop(self) -> None:
"""Остановка forwarder потока."""
if not self.running:
if not hasattr(self, 'running') or not self.running:
return
self.logger.info("Stopping InfluxDB forwarder...")
@@ -301,7 +301,7 @@ class InfluxDBClient:
return {
"enabled": self.config.enabled,
"initialized": self._initialized and self.client is not None,
"running": self.running,
"running": getattr(self, 'running', False),
"sent_count": self.sent_count,
"failed_count": self.failed_count,
"queue_size": self.message_queue.qsize(),

View File

@@ -13,7 +13,7 @@ from typing import Optional, Tuple
from logger import get_logger
from config import config
from storage import get_storage
from influxdb_client import get_influxdb_client
from influxdb_handler import get_influxdb_client
logger = get_logger(__name__)