From acd5e72f6c10886fb38b5c228f13a1145cb6bf72 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 2 Sep 2019 20:35:29 +0800 Subject: [PATCH] improve gdb for configiration --- database/gdb/gdb_config.go | 8 ++++---- frame/gins/gins.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/database/gdb/gdb_config.go b/database/gdb/gdb_config.go index 6dd9fd7a0..669b0542a 100644 --- a/database/gdb/gdb_config.go +++ b/database/gdb/gdb_config.go @@ -64,15 +64,15 @@ func SetConfig(config Config) { configs.config = config } -// 添加数据库服务器集群配置 -func AddConfigGroup(group string, nodes ConfigGroup) { +// 按照配置分组设置数据库服务器集群配置 +func SetConfigGroup(group string, nodes ConfigGroup) { defer instances.Clear() configs.Lock() defer configs.Unlock() configs.config[group] = nodes } -// 添加一台数据库服务器配置 +// 按照配置分组添加一台数据库服务器配置 func AddConfigNode(group string, node ConfigNode) { defer instances.Clear() configs.Lock() @@ -87,7 +87,7 @@ func AddDefaultConfigNode(node ConfigNode) { // 添加默认链接的数据库服务器集群配置 func AddDefaultConfigGroup(nodes ConfigGroup) { - AddConfigGroup(DEFAULT_GROUP_NAME, nodes) + SetConfigGroup(DEFAULT_GROUP_NAME, nodes) } // 添加一台数据库服务器配置 diff --git a/frame/gins/gins.go b/frame/gins/gins.go index cfff94397..d043f0c49 100644 --- a/frame/gins/gins.go +++ b/frame/gins/gins.go @@ -124,7 +124,7 @@ func Database(name ...string) gdb.DB { } } if len(cg) > 0 { - gdb.AddConfigGroup(group, cg) + gdb.SetConfigGroup(group, cg) } } // Parse as a single node configuration. @@ -134,7 +134,7 @@ func Database(name ...string) gdb.DB { cg = append(cg, *node) } if len(cg) > 0 { - gdb.AddConfigGroup(group, cg) + gdb.SetConfigGroup(group, cg) } } addConfigMonitor(instanceKey, config)