diff --git a/client/suite.go b/client/suite.go index f048564..ddbbb47 100644 --- a/client/suite.go +++ b/client/suite.go @@ -20,13 +20,6 @@ import ( "github.com/kitex-contrib/config-zookeeper/zookeeper" ) -const ( - retryConfigName = "retry" - rpcTimeoutConfigName = "rpc_timeout" - circuitBreakerConfigName = "circuit_break" - degradationConfigName = "degradation" -) - // ZookeeperClientSuite zookeeper client config suite, configure retry timeout limit and circuitbreak dynamically from zookeeper. type ZookeeperClientSuite = cwclient.ZookeeperClientSuite diff --git a/pkg/degradation/item_degradation.go b/pkg/degradation/item_degradation.go index ee1c096..c414af8 100644 --- a/pkg/degradation/item_degradation.go +++ b/pkg/degradation/item_degradation.go @@ -18,11 +18,6 @@ import ( degradation "github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/pkg/degradation" ) -var defaultConfig = &Config{ - Enable: false, - Percentage: 0, -} - type Config = degradation.Config // Container is a wrapper for Config diff --git a/server/suite.go b/server/suite.go index 0e6f04d..deff21f 100644 --- a/server/suite.go +++ b/server/suite.go @@ -20,10 +20,6 @@ import ( "github.com/kitex-contrib/config-zookeeper/zookeeper" ) -const ( - limiterConfigName = "limit" -) - // ZookeeperServerSuite zookeeper server config suite, configure limiter config dynamically from zookeeper . type ZookeeperServerSuite = cwserver.ZookeeperServerSuite diff --git a/zookeeper/parser.go b/zookeeper/parser.go index 9b6781b..7887d20 100644 --- a/zookeeper/parser.go +++ b/zookeeper/parser.go @@ -14,7 +14,9 @@ package zookeeper -import "encoding/json" +import ( + utils "github.com/cloudwego-contrib/cwgo-pkg/config/common" +) const ( //`{{$Prefix}}/{{$ClientName}}/{{$ServerName}}/{{$ConfigCategory}}` ZookeeperDefaultServer = "127.0.0.1:2181" @@ -28,24 +30,12 @@ type CustomFunction func(*ConfigParam) // ConfigParamConfig use for render the path info by go template, ref: https://pkg.go.dev/text/template // The fixed key shows as below. -type ConfigParamConfig struct { - Category string - ClientServiceName string - ServerServiceName string -} +type ConfigParamConfig = utils.ConfigParamConfig // ConfigParser the parser for zookeeper config. -type ConfigParser interface { - Decode(data string, config interface{}) error -} -type parser struct{} - -// Decode decodes the data to struct in specified format. -func (p *parser) Decode(data string, config interface{}) error { - return json.Unmarshal([]byte(data), config) -} +type ConfigParser = utils.ConfigParser // DefaultConfigParser default zookeeper config parser. -func defaultConfigParser() ConfigParser { - return &parser{} +func DefaultConfigParser() ConfigParser { + return utils.DefaultConfigParse() } diff --git a/zookeeper/uid.go b/zookeeper/uid.go index 7e91f33..7144e6f 100644 --- a/zookeeper/uid.go +++ b/zookeeper/uid.go @@ -18,8 +18,6 @@ import ( cwzook "github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/zookeeper" ) -var uniqueID int64 - // GetUniqueID get the unique id func GetUniqueID() int64 { return cwzook.GetUniqueID()