Skip to content

Commit 1f71f86

Browse files
committed
update zook
1 parent 78ee80b commit 1f71f86

File tree

6 files changed

+16
-22
lines changed

6 files changed

+16
-22
lines changed

config/zookeeper/client/circuit_breaker.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030

3131
// WithCircuitBreaker sets the circuit breaker policy from zookeeper configuration center.
3232
func WithCircuitBreaker(dest, src string, zookeeperClient zookeeper.Client, opts utils.Options) []client.Option {
33-
param, err := zookeeperClient.ClientConfigParam(&common.ConfigParamConfig{
33+
param, err := zookeeperClient.ClientConfigParam(&zookeeper.ConfigParamConfig{
3434
Category: circuitBreakerConfigName,
3535
ServerServiceName: dest,
3636
ClientServiceName: src,
@@ -85,12 +85,12 @@ func initCircuitBreaker(path string, uniqueID int64, dest string, zookeeperClien
8585
cb := circuitbreak.NewCBSuite(genServiceCBKeyWithRPCInfo)
8686
lcb := common.ThreadSafeSet{}
8787

88-
onChangeCallback := func(restoreDefault bool, data string, parser common.ConfigParser) {
88+
onChangeCallback := func(restoreDefault bool, data string, parser zookeeper.ConfigParser) {
8989
set := common.Set{}
9090
configs := map[string]circuitbreak.CBConfig{}
9191

9292
if !restoreDefault {
93-
err := parser.Decode(common.JSON, data, &configs)
93+
err := parser.Decode(data, &configs)
9494
if err != nil {
9595
klog.Warnf("[zookeeper] %s client zookeeper circuit breaker: unmarshal data %s failed: %s, skip...", path, data, err)
9696
return

config/zookeeper/client/degradation.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ package client
1717
import (
1818
"context"
1919

20-
common "github.com/cloudwego-contrib/cwgo-pkg/config/common"
21-
2220
"github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/pkg/degradation"
2321
"github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/utils"
2422
"github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/zookeeper"
@@ -27,7 +25,7 @@ import (
2725
)
2826

2927
func WithDegradation(dest, src string, zookeeperClient zookeeper.Client, opts utils.Options) []client.Option {
30-
param, err := zookeeperClient.ClientConfigParam(&common.ConfigParamConfig{
28+
param, err := zookeeperClient.ClientConfigParam(&zookeeper.ConfigParamConfig{
3129
Category: degradationConfigName,
3230
ServerServiceName: dest,
3331
ClientServiceName: src,
@@ -55,10 +53,10 @@ func WithDegradation(dest, src string, zookeeperClient zookeeper.Client, opts ut
5553

5654
func initDegradation(path string, uniqueID int64, dest string, zookeeperClient zookeeper.Client) *degradation.Container {
5755
container := degradation.NewContainer()
58-
onChangeCallback := func(restoreDefault bool, data string, parser common.ConfigParser) {
56+
onChangeCallback := func(restoreDefault bool, data string, parser zookeeper.ConfigParser) {
5957
config := &degradation.Config{}
6058
if !restoreDefault {
61-
err := parser.Decode(common.JSON, data, config)
59+
err := parser.Decode(data, config)
6260
if err != nil {
6361
klog.Warnf("[zookeeper] %s server zookeeper degradation config: unmarshal data %s failed: %s, skip...", path, data, err)
6462
return

config/zookeeper/client/retry.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
// WithRetryPolicy sets the retry policy from zookeeper configuration center.
3030
func WithRetryPolicy(dest, src string, zookeeperClient zookeeper.Client, opts utils.Options) []client.Option {
31-
param, err := zookeeperClient.ClientConfigParam(&common.ConfigParamConfig{
31+
param, err := zookeeperClient.ClientConfigParam(&zookeeper.ConfigParamConfig{
3232
Category: retryConfigName,
3333
ServerServiceName: dest,
3434
ClientServiceName: src,
@@ -59,11 +59,11 @@ func initRetryContainer(path string, uniqueID int64, dest string, zookeeperClien
5959

6060
ts := common.ThreadSafeSet{}
6161

62-
onChangeCallback := func(restoreDefault bool, data string, parser common.ConfigParser) {
62+
onChangeCallback := func(restoreDefault bool, data string, parser zookeeper.ConfigParser) {
6363
// the key is method name, wildcard "*" can match anything.
6464
rcs := map[string]*retry.Policy{}
6565
if !restoreDefault && data != "" {
66-
err := parser.Decode(common.JSON, data, &rcs)
66+
err := parser.Decode(data, &rcs)
6767
if err != nil {
6868
klog.Warnf("[zookeeper] %s client zookeeper retry: unmarshal data %s failed: %s, skip...", path, data, err)
6969
return

config/zookeeper/client/rpc_timeout.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ package client
1717
import (
1818
"context"
1919

20-
common "github.com/cloudwego-contrib/cwgo-pkg/config/common"
21-
2220
"github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/utils"
2321
"github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/zookeeper"
2422
"github.com/cloudwego/kitex/client"
@@ -29,7 +27,7 @@ import (
2927

3028
// WithRPCTimeout sets the RPC timeout policy from zookeeper configuration center.
3129
func WithRPCTimeout(dest, src string, zookeeperClient zookeeper.Client, opts utils.Options) []client.Option {
32-
param, err := zookeeperClient.ClientConfigParam(&common.ConfigParamConfig{
30+
param, err := zookeeperClient.ClientConfigParam(&zookeeper.ConfigParamConfig{
3331
Category: rpcTimeoutConfigName,
3432
ServerServiceName: dest,
3533
ClientServiceName: src,
@@ -58,10 +56,10 @@ func WithRPCTimeout(dest, src string, zookeeperClient zookeeper.Client, opts uti
5856
func initRPCTimeoutContainer(path string, uniqueID int64, dest string, zookeeperClient zookeeper.Client) rpcinfo.TimeoutProvider {
5957
rpcTimeoutContainer := rpctimeout.NewContainer()
6058

61-
onChangeCallback := func(restoreDefault bool, data string, parser common.ConfigParser) {
59+
onChangeCallback := func(restoreDefault bool, data string, parser zookeeper.ConfigParser) {
6260
configs := map[string]*rpctimeout.RPCTimeout{}
6361
if !restoreDefault {
64-
err := parser.Decode(common.JSON, data, &configs)
62+
err := parser.Decode(data, &configs)
6563
if err != nil {
6664
klog.Warnf("[zookeeper] %s client zookeeper rpc timeout: unmarshal data %s failed: %s, skip...", path, data, err)
6765
return

config/zookeeper/server/limiter.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"context"
1919
"sync/atomic"
2020

21-
common "github.com/cloudwego-contrib/cwgo-pkg/config/common"
22-
2321
"github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/utils"
2422
"github.com/cloudwego-contrib/cwgo-pkg/config/zookeeper/zookeeper"
2523
"github.com/cloudwego/kitex/pkg/klog"
@@ -30,7 +28,7 @@ import (
3028

3129
// WithLimiter sets the limiter config from zookeeper configuration center.
3230
func WithLimiter(dest string, zookeeperClient zookeeper.Client, opts utils.Options) server.Option {
33-
param, err := zookeeperClient.ServerConfigParam(&common.ConfigParamConfig{
31+
param, err := zookeeperClient.ServerConfigParam(&zookeeper.ConfigParamConfig{
3432
Category: limiterConfigName,
3533
ServerServiceName: dest,
3634
})
@@ -57,10 +55,10 @@ func initLimitOptions(path string, uniqueID int64, dest string, zookeeperClient
5755
u.UpdateLimit(opt)
5856
updater.Store(u)
5957
}
60-
onChangeCallback := func(restoreDefault bool, data string, parser common.ConfigParser) {
58+
onChangeCallback := func(restoreDefault bool, data string, parser zookeeper.ConfigParser) {
6159
lc := &limiter.LimiterConfig{}
6260
if !restoreDefault && data != "" {
63-
err := parser.Decode(common.JSON, data, lc)
61+
err := parser.Decode(data, lc)
6462
if err != nil {
6563
klog.Warnf("[zookeeper] %s server zookeeper config: unmarshal data %s failed: %s, skip...", dest, data, err)
6664
return

registry/nacos/nacoskitex/v2/registry/registry_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func TestNacosMultipleInstancesWithDefaultNacosRegistry(t *testing.T) {
190190
HealthyOnly: true,
191191
})
192192
if err != nil {
193-
assert.Equal(t, "instance list is empty", err.Error())
193+
assert.Equal(t, "instance list is empty!", err.Error())
194194
} else {
195195
assert.Equal(t, 0, len(res))
196196
}

0 commit comments

Comments
 (0)