Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update nacos version to 2.1.2 #106

Merged
merged 9 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions database/kv/nacos/config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
)

import (
"github.com/nacos-group/nacos-sdk-go/clients"
"github.com/nacos-group/nacos-sdk-go/clients/config_client"
"github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/vo"
"github.com/nacos-group/nacos-sdk-go/v2/clients"
"github.com/nacos-group/nacos-sdk-go/v2/clients/config_client"
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
"github.com/nacos-group/nacos-sdk-go/v2/vo"
)

var (
Expand Down Expand Up @@ -120,11 +120,13 @@ func (n *NacosConfigClient) Close() {
n.activeCount--
if n.share {
if n.activeCount == 0 {
n.client.CloseClient()
n.client = nil
atomic.StoreUint32(&n.valid, 0)
delete(configClientPool.configClient, n.name)
}
} else {
n.client.CloseClient()
n.client = nil
atomic.StoreUint32(&n.valid, 0)
delete(configClientPool.configClient, n.name)
Expand Down
9 changes: 4 additions & 5 deletions database/kv/nacos/config_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
)

import (
"github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/vo"
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
"github.com/nacos-group/nacos-sdk-go/v2/vo"

"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestNewNacosConfigClient(t *testing.T) {

func TestPublishConfig(t *testing.T) {

scs := []constant.ServerConfig{*constant.NewServerConfig("console.nacos.io", 80)}
scs := []constant.ServerConfig{*constant.NewServerConfig("console.nacos.io", 8848)}

cc := constant.ClientConfig{
AppName: "nacos",
Expand All @@ -89,8 +89,7 @@ func TestPublishConfig(t *testing.T) {
NotLoadCacheAtStart: true,
LogDir: "/tmp/nacos/log",
CacheDir: "/tmp/nacos/cache",
RotateTime: "1h",
MaxAge: 3,
LogRollingConfig: &constant.ClientLogRollingConfig{MaxAge: 3},
LogLevel: "debug",
}

Expand Down
10 changes: 6 additions & 4 deletions database/kv/nacos/naming_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
)

import (
"github.com/nacos-group/nacos-sdk-go/clients"
"github.com/nacos-group/nacos-sdk-go/clients/naming_client"
"github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/vo"
"github.com/nacos-group/nacos-sdk-go/v2/clients"
"github.com/nacos-group/nacos-sdk-go/v2/clients/naming_client"
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
"github.com/nacos-group/nacos-sdk-go/v2/vo"
)

var (
Expand Down Expand Up @@ -121,11 +121,13 @@ func (n *NacosNamingClient) Close() {
n.activeCount--
if n.share {
if n.activeCount == 0 {
n.client.CloseClient()
n.client = nil
atomic.StoreUint32(&n.valid, 0)
delete(namingClientPool.namingClient, n.name)
}
} else {
n.client.CloseClient()
n.client = nil
atomic.StoreUint32(&n.valid, 0)
delete(namingClientPool.namingClient, n.name)
Expand Down
17 changes: 8 additions & 9 deletions database/kv/nacos/naming_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ import (
)

import (
"github.com/nacos-group/nacos-sdk-go/common/constant"

"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
"github.com/stretchr/testify/assert"
)

func TestNewNacosClient(t *testing.T) {

scs := []constant.ServerConfig{
*constant.NewServerConfig("console.nacos.io", 80),
*constant.NewServerConfig("console.nacos.io", 8848),
}

cc := constant.ClientConfig{
Expand All @@ -39,16 +38,16 @@ func TestNewNacosClient(t *testing.T) {
}

client1, err := NewNacosNamingClient("nacos", true, scs, cc)
assert.Nil(t, err)
assert.True(t, err == nil && client1 != nil)
client2, err := NewNacosNamingClient("nacos", true, scs, cc)
assert.Nil(t, err)
assert.True(t, err == nil && client2 != nil)
client3, err := NewNacosNamingClient("nacos", false, scs, cc)
assert.Nil(t, err)
assert.True(t, err == nil && client3 != nil)
client4, err := NewNacosNamingClient("test", true, scs, cc)
assert.Nil(t, err)
assert.True(t, err == nil && client4 != nil)

assert.Equal(t, client1, client2)
binbin0325 marked this conversation as resolved.
Show resolved Hide resolved
assert.Equal(t, client1.activeCount, uint32(2))
assert.NotEqual(t, client1, client3)
assert.NotEqual(t, client1, client4)
assert.True(t, client1 != client3)
assert.True(t, client1 != client4)
}
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/k0kubun/pp v3.0.1+incompatible
github.com/mattn/go-isatty v0.0.14
github.com/nacos-group/nacos-sdk-go v1.0.8
github.com/nacos-group/nacos-sdk-go/v2 v2.1.2
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/pkg/errors v0.9.1
github.com/shirou/gopsutil/v3 v3.22.2
Expand All @@ -20,9 +20,8 @@ require (
go.etcd.io/etcd/client/v3 v3.5.0-alpha.0
go.etcd.io/etcd/server/v3 v3.5.0-alpha.0
go.uber.org/atomic v1.9.0
go.uber.org/zap v1.16.0
go.uber.org/zap v1.21.0
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
google.golang.org/grpc v1.36.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
google.golang.org/grpc v1.48.0
gopkg.in/yaml.v2 v2.4.0
)
Loading