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
0324568f
Commit
0324568f
authored
5 years ago
by
邹毅贤
Browse files
Options
Downloads
Patches
Plain Diff
update apollo
parent
51831409
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/base_config_test.go
+15
-0
15 additions, 0 deletions
config/base_config_test.go
config_center/apollo/impl.go
+15
-17
15 additions, 17 deletions
config_center/apollo/impl.go
with
30 additions
and
17 deletions
config/base_config_test.go
+
15
−
0
View file @
0324568f
...
...
@@ -29,6 +29,7 @@ import (
"github.com/apache/dubbo-go/common/config"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/config_center"
_
"github.com/apache/dubbo-go/config_center/apollo"
)
func
Test_refresh
(
t
*
testing
.
T
)
{
...
...
@@ -490,6 +491,20 @@ func Test_startConfigCenter(t *testing.T) {
assert
.
Equal
(
t
,
"ikurento.com"
,
v
)
}
func
Test_startApolloConfigCenter
(
t
*
testing
.
T
)
{
c
:=
&
BaseConfig
{
ConfigCenterConfig
:
&
ConfigCenterConfig
{
Protocol
:
"apollo"
,
Address
:
"106.12.25.204:8080"
,
Group
:
"mockDubbo"
,
ConfigFile
:
"mockDubbo.properties"
,
}}
err
:=
c
.
startConfigCenter
(
context
.
Background
())
assert
.
NoError
(
t
,
err
)
b
,
v
:=
config
.
GetEnvInstance
()
.
Configuration
()
.
Back
()
.
Value
.
(
*
config
.
InmemoryConfiguration
)
.
GetProperty
(
"dubbo.application.organization"
)
assert
.
True
(
t
,
b
)
assert
.
Equal
(
t
,
"ikurento.com"
,
v
)
}
func
Test_initializeStruct
(
t
*
testing
.
T
)
{
consumerConfig
:=
&
ConsumerConfig
{}
tp
:=
reflect
.
TypeOf
(
ConsumerConfig
{})
...
...
This diff is collapsed.
Click to expand it.
config_center/apollo/impl.go
+
15
−
17
View file @
0324568f
...
...
@@ -18,6 +18,8 @@ limitations under the License.
package
apollo
import
(
"fmt"
"github.com/go-errors/errors"
"os"
"strconv"
"strings"
...
...
@@ -37,6 +39,7 @@ const (
apolloAddrKey
=
"apollo.meta"
apolloClusterKey
=
"apollo.cluster"
apolloProtocolPrefix
=
"http://"
apolloConfigFormat
=
"%s.%s"
)
type
apolloDynamicConfiguration
struct
{
...
...
@@ -68,7 +71,7 @@ func newApolloDynamicConfiguration(url *common.URL) (*apolloDynamicConfiguration
readyConfig
:=
&
agollo
.
AppConfig
{
AppId
:
appId
,
Cluster
:
configCluster
,
NamespaceName
:
namespace
,
NamespaceName
:
getNamespaceName
(
namespace
,
agollo
.
YML
)
,
Ip
:
configAddr
,
}
...
...
@@ -76,9 +79,7 @@ func newApolloDynamicConfiguration(url *common.URL) (*apolloDynamicConfiguration
return
readyConfig
,
nil
})
agollo
.
Start
()
return
c
,
nil
return
c
,
agollo
.
Start
()
}
type
apolloChangeListener
struct
{
...
...
@@ -142,6 +143,10 @@ func (c *apolloDynamicConfiguration) RemoveListener(key string, listener config_
}
}
func
getNamespaceName
(
namespace
string
,
configFileFormat
agollo
.
ConfigFileFormat
)
string
{
return
fmt
.
Sprintf
(
apolloConfigFormat
,
namespace
,
configFileFormat
)
}
func
(
c
*
apolloDynamicConfiguration
)
GetConfig
(
key
string
,
opts
...
config_center
.
Option
)
(
string
,
error
)
{
k
:=
&
config_center
.
Options
{}
for
_
,
opt
:=
range
opts
{
...
...
@@ -149,20 +154,13 @@ func (c *apolloDynamicConfiguration) GetConfig(key string, opts ...config_center
}
group
:=
k
.
Group
if
len
(
group
)
!=
0
&&
c
.
url
.
GetParam
(
constant
.
CONFIG_GROUP_KEY
,
config_center
.
DEFAULT_GROUP
)
!=
group
{
readyConfig
:=
&
agollo
.
AppConfig
{
AppId
:
c
.
appConf
.
AppId
,
Cluster
:
c
.
appConf
.
Cluster
,
NamespaceName
:
"application"
,
Ip
:
c
.
appConf
.
Ip
,
namespace
:=
c
.
url
.
GetParam
(
constant
.
CONFIG_GROUP_KEY
,
config_center
.
DEFAULT_GROUP
)
fileNamespace
:=
getNamespaceName
(
namespace
,
agollo
.
Properties
)
config
:=
agollo
.
GetConfig
(
fileNamespace
)
if
config
==
nil
{
return
""
,
errors
.
New
(
fmt
.
Sprintf
(
"nothiing in namespace:%s "
,
fileNamespace
))
}
agollo
.
InitCustomConfig
(
func
()
(
*
agollo
.
AppConfig
,
error
)
{
return
readyConfig
,
nil
})
agollo
.
Start
()
//Config config = ConfigService.getAppConfig();
//return config.getProperty(key, null);
return
config
.
GetContent
(),
nil
}
return
agollo
.
GetStringValue
(
key
,
""
),
nil
}
...
...
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