Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
1b3c7cca
Commit
1b3c7cca
authored
4 years ago
by
Ming Deng
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #475 from flycash/nacos-batch-bk
implement GetConfigKeysByGroup
parents
95a5a127
88a43fd7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config_center/nacos/impl.go
+21
-4
21 additions, 4 deletions
config_center/nacos/impl.go
config_center/nacos/impl_test.go
+29
-1
29 additions, 1 deletion
config_center/nacos/impl_test.go
go.mod
+3
-13
3 additions, 13 deletions
go.mod
go.sum
+6
-0
6 additions, 0 deletions
go.sum
with
59 additions
and
18 deletions
config_center/nacos/impl.go
+
21
−
4
View file @
1b3c7cca
...
@@ -36,7 +36,10 @@ import (
...
@@ -36,7 +36,10 @@ import (
"github.com/apache/dubbo-go/config_center/parser"
"github.com/apache/dubbo-go/config_center/parser"
)
)
const
nacosClientName
=
"nacos config_center"
const
(
nacosClientName
=
"nacos config_center"
maxKeysNum
=
9999
)
type
nacosDynamicConfiguration
struct
{
type
nacosDynamicConfiguration
struct
{
url
*
common
.
URL
url
*
common
.
URL
...
@@ -108,9 +111,23 @@ func (n *nacosDynamicConfiguration) PublishConfig(key string, group string, valu
...
@@ -108,9 +111,23 @@ func (n *nacosDynamicConfiguration) PublishConfig(key string, group string, valu
// GetConfigKeysByGroup will return all keys with the group
// GetConfigKeysByGroup will return all keys with the group
func
(
n
*
nacosDynamicConfiguration
)
GetConfigKeysByGroup
(
group
string
)
(
*
gxset
.
HashSet
,
error
)
{
func
(
n
*
nacosDynamicConfiguration
)
GetConfigKeysByGroup
(
group
string
)
(
*
gxset
.
HashSet
,
error
)
{
// TODO (the golang client of nacos does not support batch API)
group
=
n
.
resolvedGroup
(
group
)
// we should build a issue and then think about how to resolve this problem
page
,
err
:=
(
*
n
.
client
.
Client
())
.
SearchConfig
(
vo
.
SearchConfigParm
{
return
nil
,
perrors
.
New
(
"unsupport operation, wait for implement"
)
Search
:
"accurate"
,
Group
:
group
,
PageNo
:
1
,
// actually it's impossible for user to create 9999 application under one group
PageSize
:
maxKeysNum
,
})
result
:=
gxset
.
NewSet
()
if
err
!=
nil
{
return
result
,
perrors
.
WithMessage
(
err
,
"can not find the client config"
)
}
for
_
,
itm
:=
range
page
.
PageItems
{
result
.
Add
(
itm
.
Content
)
}
return
result
,
nil
}
}
// GetRule Get router rule
// GetRule Get router rule
...
...
This diff is collapsed.
Click to expand it.
config_center/nacos/impl_test.go
+
29
−
1
View file @
1b3c7cca
...
@@ -88,6 +88,34 @@ func Test_GetConfig(t *testing.T) {
...
@@ -88,6 +88,34 @@ func Test_GetConfig(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
}
}
func
TestNacosDynamicConfiguration_GetConfigKeysByGroup
(
t
*
testing
.
T
)
{
data
:=
`
{
"PageItems": [
{
"Content": "application"
}
]
}
`
ts
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Write
([]
byte
(
data
))
}))
nacosURL
:=
strings
.
ReplaceAll
(
ts
.
URL
,
"http"
,
"registry"
)
regurl
,
_
:=
common
.
NewURL
(
nacosURL
)
nacosConfiguration
,
err
:=
newNacosDynamicConfiguration
(
&
regurl
)
assert
.
NoError
(
t
,
err
)
nacosConfiguration
.
SetParser
(
&
parser
.
DefaultConfigurationParser
{})
configs
,
err
:=
nacosConfiguration
.
GetConfigKeysByGroup
(
"dubbo"
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
1
,
configs
.
Size
())
assert
.
True
(
t
,
configs
.
Contains
(
"application"
))
}
func
TestNacosDynamicConfiguration_PublishConfig
(
t
*
testing
.
T
)
{
func
TestNacosDynamicConfiguration_PublishConfig
(
t
*
testing
.
T
)
{
nacos
,
err
:=
initNacosData
(
t
)
nacos
,
err
:=
initNacosData
(
t
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
...
@@ -109,7 +137,7 @@ func Test_AddListener(t *testing.T) {
...
@@ -109,7 +137,7 @@ func Test_AddListener(t *testing.T) {
}
}
func
Test_RemoveListener
(
t
*
testing
.
T
)
{
func
Test_RemoveListener
(
t
*
testing
.
T
)
{
//TODO not supported in current go_nacos_sdk version
//
TODO not supported in current go_nacos_sdk version
}
}
type
mockDataListener
struct
{
type
mockDataListener
struct
{
...
...
This diff is collapsed.
Click to expand it.
go.mod
+
3
−
13
View file @
1b3c7cca
...
@@ -3,9 +3,7 @@ module github.com/apache/dubbo-go
...
@@ -3,9 +3,7 @@ module github.com/apache/dubbo-go
require (
require (
github.com/Workiva/go-datastructures
v1.0.52
github.com/Workiva/go-datastructures
v1.0.52
github.com/afex/hystrix-go
v0.0.0-20180502004556-fa1af6a1f4f5
github.com/afex/hystrix-go
v0.0.0-20180502004556-fa1af6a1f4f5
github.com/aliyun/alibaba-cloud-sdk-go
v0.0.0-20190802083043-4cd0c391755e // indirect
github.com/apache/dubbo-go-hessian2
v1.4.0
github.com/apache/dubbo-go-hessian2
v1.4.0
github.com/buger/jsonparser
v0.0.0-20181115193947-bf1c66bbce23 // indirect
github.com/coreos/bbolt
v1.3.3 // indirect
github.com/coreos/bbolt
v1.3.3 // indirect
github.com/coreos/etcd
v3.3.13+incompatible
github.com/coreos/etcd
v3.3.13+incompatible
github.com/coreos/go-semver
v0.3.0 // indirect
github.com/coreos/go-semver
v0.3.0 // indirect
...
@@ -16,8 +14,6 @@ require (
...
@@ -16,8 +14,6 @@ require (
github.com/dubbogo/go-zookeeper
v1.0.0
github.com/dubbogo/go-zookeeper
v1.0.0
github.com/dubbogo/gost
v1.8.0
github.com/dubbogo/gost
v1.8.0
github.com/emicklei/go-restful/v3
v3.0.0
github.com/emicklei/go-restful/v3
v3.0.0
github.com/fastly/go-utils
v0.0.0-20180712184237-d95a45783239 // indirect
github.com/go-errors/errors
v1.0.1 // indirect
github.com/go-resty/resty/v2
v2.1.0
github.com/go-resty/resty/v2
v2.1.0
github.com/golang/groupcache
v0.0.0-20190702054246-869f871628b6 // indirect
github.com/golang/groupcache
v0.0.0-20190702054246-869f871628b6 // indirect
github.com/golang/mock
v1.3.1
github.com/golang/mock
v1.3.1
...
@@ -29,32 +25,26 @@ require (
...
@@ -29,32 +25,26 @@ require (
github.com/grpc-ecosystem/grpc-opentracing
v0.0.0-20180507213350-8e809c8a8645
github.com/grpc-ecosystem/grpc-opentracing
v0.0.0-20180507213350-8e809c8a8645
github.com/hashicorp/consul
v1.5.3
github.com/hashicorp/consul
v1.5.3
github.com/hashicorp/consul/api
v1.1.0
github.com/hashicorp/consul/api
v1.1.0
github.com/jehiah/go-strftime
v0.0.0-20171201141054-1d33003b3869 // indirect
github.com/jinzhu/copier
v0.0.0-20190625015134-976e0346caa8
github.com/jinzhu/copier
v0.0.0-20190625015134-976e0346caa8
github.com/jonboulle/clockwork
v0.1.0 // indirect
github.com/lestrrat/go-envload
v0.0.0-20180220120943-6ed08b54a570 // indirect
github.com/lestrrat/go-file-rotatelogs
v0.0.0-20180223000712-d3151e2a480f // indirect
github.com/lestrrat/go-strftime
v0.0.0-20180220042222-ba3bf9c1d042 // indirect
github.com/magiconair/properties
v1.8.1
github.com/magiconair/properties
v1.8.1
github.com/mitchellh/mapstructure
v1.1.2
github.com/mitchellh/mapstructure
v1.1.2
github.com/modern-go/concurrent
v0.0.0-20180306012644-bacd9c7ef1dd
github.com/modern-go/concurrent
v0.0.0-20180306012644-bacd9c7ef1dd
github.com/nacos-group/nacos-sdk-go
v0.
0
.0
-20191128082542-fe1b325b125c
github.com/nacos-group/nacos-sdk-go
v0.
3
.0
github.com/opentracing/opentracing-go
v1.1.0
github.com/opentracing/opentracing-go
v1.1.0
github.com/pkg/errors
v0.
8
.1
github.com/pkg/errors
v0.
9
.1
github.com/prometheus/client_golang
v1.1.0
github.com/prometheus/client_golang
v1.1.0
github.com/satori/go.uuid
v1.2.0
github.com/satori/go.uuid
v1.2.0
github.com/smartystreets/goconvey
v0.0.0-20190710185942-9d28bd7c0945 // indirect
github.com/smartystreets/goconvey
v0.0.0-20190710185942-9d28bd7c0945 // indirect
github.com/soheilhy/cmux
v0.1.4 // indirect
github.com/soheilhy/cmux
v0.1.4 // indirect
github.com/stretchr/testify
v1.5.1
github.com/stretchr/testify
v1.5.1
github.com/tebeka/strftime
v0.1.3 // indirect
github.com/tmc/grpc-websocket-proxy
v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/tmc/grpc-websocket-proxy
v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/toolkits/concurrent
v0.0.0-20150624120057-a4371d70e3e3 // indirect
github.com/xiang90/probing
v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/xiang90/probing
v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/zouyx/agollo
v0.0.0-20191114083447-dde9fc9f35b8
github.com/zouyx/agollo
v0.0.0-20191114083447-dde9fc9f35b8
go.etcd.io/bbolt
v1.3.3 // indirect
go.etcd.io/bbolt
v1.3.3 // indirect
go.etcd.io/etcd
v3.3.13+incompatible
go.etcd.io/etcd
v3.3.13+incompatible
go.uber.org/atomic
v1.4.0
go.uber.org/atomic
v1.4.0
go.uber.org/zap
v1.10.0
go.uber.org/zap
v1.10.0
golang.org/x/time
v0.0.0-20190308202827-9d24e82272b4 // indirect
google.golang.org/grpc
v1.22.1
google.golang.org/grpc
v1.22.1
gopkg.in/yaml.v2
v2.2.2
gopkg.in/yaml.v2
v2.2.2
k8s.io/api
v0.0.0-20190325185214-7544f9db76f6
k8s.io/api
v0.0.0-20190325185214-7544f9db76f6
...
...
This diff is collapsed.
Click to expand it.
go.sum
+
6
−
0
View file @
1b3c7cca
...
@@ -37,6 +37,8 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
...
@@ -37,6 +37,8 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
github.com/alecthomas/units
v0.0.0-20151022065526-2efee857e7cf/go.mod h1:
ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units
v0.0.0-20151022065526-2efee857e7cf/go.mod h1:
ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/aliyun/alibaba-cloud-sdk-go
v0.0.0-20190802083043-4cd0c391755e h1:
MSuLXx/mveDbpDNhVrcWTMeV4lbYWKcyO4rH+jAxmX0=
github.com/aliyun/alibaba-cloud-sdk-go
v0.0.0-20190802083043-4cd0c391755e h1:
MSuLXx/mveDbpDNhVrcWTMeV4lbYWKcyO4rH+jAxmX0=
github.com/aliyun/alibaba-cloud-sdk-go
v0.0.0-20190802083043-4cd0c391755e/go.mod h1:
myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ=
github.com/aliyun/alibaba-cloud-sdk-go
v0.0.0-20190802083043-4cd0c391755e/go.mod h1:
myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ=
github.com/aliyun/alibaba-cloud-sdk-go
v1.61.18 h1:
zOVTBdCKFd9JbCKz9/nt+FovbjPFmb7mUnp8nH9fQBA=
github.com/aliyun/alibaba-cloud-sdk-go
v1.61.18/go.mod h1:
v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk=
github.com/aliyun/aliyun-oss-go-sdk
v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:
T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/aliyun/aliyun-oss-go-sdk
v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:
T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/apache/dubbo-go-hessian2
v1.4.0 h1:
Cb9FQVTy3G93dnDr7P93U8DeKFYpDTJjQp44JG5TafA=
github.com/apache/dubbo-go-hessian2
v1.4.0 h1:
Cb9FQVTy3G93dnDr7P93U8DeKFYpDTJjQp44JG5TafA=
github.com/apache/dubbo-go-hessian2
v1.4.0/go.mod h1:
VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8=
github.com/apache/dubbo-go-hessian2
v1.4.0/go.mod h1:
VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8=
...
@@ -384,6 +386,8 @@ github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8m
...
@@ -384,6 +386,8 @@ github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8m
github.com/mwitkow/go-conntrack
v0.0.0-20161129095857-cc309e4a2223/go.mod h1:
qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack
v0.0.0-20161129095857-cc309e4a2223/go.mod h1:
qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nacos-group/nacos-sdk-go
v0.0.0-20191128082542-fe1b325b125c h1:
WoCa3AvgQMVKNs+RIFlWPRgY9QVJwUxJDrGxHs0fcRo=
github.com/nacos-group/nacos-sdk-go
v0.0.0-20191128082542-fe1b325b125c h1:
WoCa3AvgQMVKNs+RIFlWPRgY9QVJwUxJDrGxHs0fcRo=
github.com/nacos-group/nacos-sdk-go
v0.0.0-20191128082542-fe1b325b125c/go.mod h1:
CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo=
github.com/nacos-group/nacos-sdk-go
v0.0.0-20191128082542-fe1b325b125c/go.mod h1:
CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo=
github.com/nacos-group/nacos-sdk-go
v0.3.0 h1:
2v2QmihtyX6ZUXAN+ya+5h2pedn7R5M+WJwSJPFsuMY=
github.com/nacos-group/nacos-sdk-go
v0.3.0/go.mod h1:
ESKb6yF0gxSc8GuS+0jaMBe+n8rJ5/k4ya6LyFG2xi8=
github.com/nicolai86/scaleway-sdk
v1.10.2-0.20180628010248-798f60e20bb2 h1:
BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s=
github.com/nicolai86/scaleway-sdk
v1.10.2-0.20180628010248-798f60e20bb2 h1:
BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s=
github.com/nicolai86/scaleway-sdk
v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:
TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk=
github.com/nicolai86/scaleway-sdk
v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:
TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk=
github.com/oklog/run
v0.0.0-20180308005104-6934b124db28 h1:
Hbr3fbVPXea52oPQeP7KLSxP52g6SFaNY1IqAmUyEW0=
github.com/oklog/run
v0.0.0-20180308005104-6934b124db28 h1:
Hbr3fbVPXea52oPQeP7KLSxP52g6SFaNY1IqAmUyEW0=
...
@@ -417,6 +421,8 @@ github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR
...
@@ -417,6 +421,8 @@ github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR
github.com/pkg/errors
v0.8.0/go.mod h1:
bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors
v0.8.0/go.mod h1:
bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors
v0.8.1 h1:
iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors
v0.8.1 h1:
iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors
v0.8.1/go.mod h1:
bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors
v0.8.1/go.mod h1:
bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors
v0.9.1 h1:
FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors
v0.9.1/go.mod h1:
bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib
v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:
iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib
v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:
iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib
v1.0.0 h1:
4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib
v1.0.0 h1:
4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib
v1.0.0/go.mod h1:
iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib
v1.0.0/go.mod h1:
iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment