数据库管理器单例模式

This commit is contained in:
liuwei
2025-03-19 09:55:08 +08:00
parent 85d3f06baf
commit d2e7ca8976
7 changed files with 41 additions and 25 deletions

View File

@@ -51,7 +51,7 @@ class StatsCollectorPlugin(PluginInterface):
}
self.event_manager = EventManager.get_instance()
self.db_manager = DBConnectionManager()
self.db_manager = DBConnectionManager.get_instance()
self.stats_db = StatsDBOperator(self.db_manager)
def initialize(self, config: Dict[str, Any]) -> bool:

View File

@@ -21,7 +21,7 @@ class DashboardServer:
self.logger = logging.getLogger("DashboardServer")
# 修正:使用单例模式获取数据库连接
self.db_manager = DBConnectionManager()
self.db_manager = DBConnectionManager.get_instance()
self.stats_db = StatsDBOperator(self.db_manager)
self.app = self._create_app()
self._stop_event = threading.Event()