Own ConfigManager in Core; resolve config via DI instead of the singleton
Core holds a ConfigManager member, keeps it synced (updateConfig(config_)), and provides it as a service. ConfigManager.cpp drops the instance() definition. MusicManager gets the manager via setConfigManager() and reads sections through it (former ECHOION_BOT/YOUTUBE/NETWORK sites); RpcInfoCommand resolves it from the registry via ctx.service<Api::ConfigManager>(). Build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7553d10d3
commit
0e08ccaefa
6 files changed
+29
-14
No files matched your search
+3
-2
@@ -65,7 +65,7 @@ namespace Echoion::Core
|
||||
}
|
||||
|
||||
// Initialize global ConfigManager with loaded config
|
||||
Api::ConfigManager::instance().updateConfig(config_, false);
|
||||
configManager_.updateConfig(config_, false);
|
||||
ECHOION_LOG_INFO("Global ConfigManager initialized");
|
||||
|
||||
// Note: logLevel was removed from BotConfig, using Debug as default
|
||||
@@ -110,6 +110,7 @@ namespace Echoion::Core
|
||||
// Initialize music manager
|
||||
musicManager_ = std::make_shared<MusicManager>();
|
||||
musicManager_->setEventBus(&eventBus_);
|
||||
musicManager_->setConfigManager(&configManager_);
|
||||
auto musicResult = musicManager_->initialize(networkClient_, database_);
|
||||
if (!musicResult) {
|
||||
return std::unexpected(musicResult.error());
|
||||
@@ -306,7 +307,7 @@ namespace Echoion::Core
|
||||
registry_.provide<Api::ILogger>(logger);
|
||||
}
|
||||
registry_.provide<Api::ConfigManager>(
|
||||
alias(&Api::ConfigManager::instance()));
|
||||
alias(&configManager_));
|
||||
registry_.provide<Void::EventBus::EventBus>(alias(&eventBus_));
|
||||
if (networkClient_) {
|
||||
registry_.provide<Api::INetworkClient>(networkClient_);
|
||||
|
||||
Reference in new issue
Block a user