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
a77b5ba2
Commit
a77b5ba2
authored
4 years ago
by
AlexStocks
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://github.com/apache/dubbo-go
parents
281cf0a7
a85c76bc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/constant/key.go
+1
-0
1 addition, 0 deletions
common/constant/key.go
registry/nacos/registry.go
+11
-3
11 additions, 3 deletions
registry/nacos/registry.go
registry/nacos/registry_test.go
+20
-4
20 additions, 4 deletions
registry/nacos/registry_test.go
with
32 additions
and
7 deletions
common/constant/key.go
+
1
−
0
View file @
a77b5ba2
...
...
@@ -173,6 +173,7 @@ const (
NACOS_NAMESPACE_ID
=
"namespaceId"
NACOS_PASSWORD
=
"password"
NACOS_USERNAME
=
"username"
NACOS_NOT_LOAD_LOCAL_CACHE
=
"nacos.not.load.cache"
)
const
(
...
...
This diff is collapsed.
Click to expand it.
registry/nacos/registry.go
+
11
−
3
View file @
a77b5ba2
...
...
@@ -274,7 +274,7 @@ func getNacosConfig(url *common.URL) (map[string]interface{}, error) {
Port
:
uint64
(
port
),
})
}
configMap
[
"serverConfigs"
]
=
serverConfigs
configMap
[
nacosConstant
.
KEY_SERVER_CONFIGS
]
=
serverConfigs
var
clientConfig
nacosConstant
.
ClientConfig
timeout
,
err
:=
time
.
ParseDuration
(
url
.
GetParam
(
constant
.
REGISTRY_TIMEOUT_KEY
,
constant
.
DEFAULT_REG_TIMEOUT
))
...
...
@@ -287,8 +287,16 @@ func getNacosConfig(url *common.URL) (map[string]interface{}, error) {
clientConfig
.
LogDir
=
url
.
GetParam
(
constant
.
NACOS_LOG_DIR_KEY
,
""
)
clientConfig
.
Endpoint
=
url
.
GetParam
(
constant
.
NACOS_ENDPOINT
,
""
)
clientConfig
.
NamespaceId
=
url
.
GetParam
(
constant
.
NACOS_NAMESPACE_ID
,
""
)
clientConfig
.
NotLoadCacheAtStart
=
true
configMap
[
"clientConfig"
]
=
clientConfig
//enable local cache when nacos can not connect.
notLoadCache
,
err
:=
strconv
.
ParseBool
(
url
.
GetParam
(
constant
.
NACOS_NOT_LOAD_LOCAL_CACHE
,
"false"
))
if
err
!=
nil
{
logger
.
Errorf
(
"ParseBool - error: %v"
,
err
)
notLoadCache
=
false
}
clientConfig
.
NotLoadCacheAtStart
=
notLoadCache
configMap
[
nacosConstant
.
KEY_CLIENT_CONFIG
]
=
clientConfig
return
configMap
,
nil
}
This diff is collapsed.
Click to expand it.
registry/nacos/registry_test.go
+
20
−
4
View file @
a77b5ba2
...
...
@@ -40,7 +40,11 @@ func TestNacosRegistry_Register(t *testing.T) {
if
!
checkNacosServerAlive
()
{
return
}
regurl
,
_
:=
common
.
NewURL
(
"registry://console.nacos.io:80"
,
common
.
WithParamsValue
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
)))
regurlMap
:=
url
.
Values
{}
regurlMap
.
Set
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
))
regurlMap
.
Set
(
constant
.
NACOS_NOT_LOAD_LOCAL_CACHE
,
"true"
)
regurl
,
_
:=
common
.
NewURL
(
"registry://console.nacos.io:80"
,
common
.
WithParams
(
regurlMap
))
urlMap
:=
url
.
Values
{}
urlMap
.
Set
(
constant
.
GROUP_KEY
,
"guangzhou-idc"
)
urlMap
.
Set
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
))
...
...
@@ -72,7 +76,11 @@ func TestNacosRegistry_Subscribe(t *testing.T) {
if
!
checkNacosServerAlive
()
{
return
}
regurl
,
_
:=
common
.
NewURL
(
"registry://console.nacos.io:80"
,
common
.
WithParamsValue
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
)))
regurlMap
:=
url
.
Values
{}
regurlMap
.
Set
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
))
regurlMap
.
Set
(
constant
.
NACOS_NOT_LOAD_LOCAL_CACHE
,
"true"
)
regurl
,
_
:=
common
.
NewURL
(
"registry://console.nacos.io:80"
,
common
.
WithParams
(
regurlMap
))
urlMap
:=
url
.
Values
{}
urlMap
.
Set
(
constant
.
GROUP_KEY
,
"guangzhou-idc"
)
urlMap
.
Set
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
))
...
...
@@ -113,7 +121,11 @@ func TestNacosRegistry_Subscribe_del(t *testing.T) {
if
!
checkNacosServerAlive
()
{
return
}
regurl
,
_
:=
common
.
NewURL
(
"registry://console.nacos.io:80"
,
common
.
WithParamsValue
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
)))
regurlMap
:=
url
.
Values
{}
regurlMap
.
Set
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
))
regurlMap
.
Set
(
constant
.
NACOS_NOT_LOAD_LOCAL_CACHE
,
"true"
)
regurl
,
_
:=
common
.
NewURL
(
"registry://console.nacos.io:80"
,
common
.
WithParams
(
regurlMap
))
urlMap
:=
url
.
Values
{}
urlMap
.
Set
(
constant
.
GROUP_KEY
,
"guangzhou-idc"
)
urlMap
.
Set
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
))
...
...
@@ -181,7 +193,11 @@ func TestNacosRegistry_Subscribe_del(t *testing.T) {
}
func
TestNacosListener_Close
(
t
*
testing
.
T
)
{
regurl
,
_
:=
common
.
NewURL
(
"registry://console.nacos.io:80"
,
common
.
WithParamsValue
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
)))
regurlMap
:=
url
.
Values
{}
regurlMap
.
Set
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
))
regurlMap
.
Set
(
constant
.
NACOS_NOT_LOAD_LOCAL_CACHE
,
"true"
)
regurl
,
_
:=
common
.
NewURL
(
"registry://console.nacos.io:80"
,
common
.
WithParams
(
regurlMap
))
urlMap
:=
url
.
Values
{}
urlMap
.
Set
(
constant
.
GROUP_KEY
,
"guangzhou-idc"
)
urlMap
.
Set
(
constant
.
ROLE_KEY
,
strconv
.
Itoa
(
common
.
PROVIDER
))
...
...
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