Skip to content
Snippets Groups Projects
Commit 76441295 authored by LaurenceLiZhixin's avatar LaurenceLiZhixin
Browse files

feat: add triple hessian support

parents 4b6e2a5f f486b3f6
No related branches found
No related tags found
No related merge requests found
Showing
with 181 additions and 68 deletions
......@@ -56,7 +56,7 @@ jobs:
- name: gofmt
run: |
go fmt ./... && git checkout -- go.mod && git status && [[ -z `git status -s` ]]
go fmt ./... && git status && [[ -z `git status -s` ]]
# diff -u <(echo -n) <(gofmt -d -s .)
- name: Install go ci lint
......@@ -69,9 +69,9 @@ jobs:
run: |
make verify
# - name: Integrate Test
# run: |
# chmod +x integrate_test.sh && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}}
- name: Integrate Test
run: |
chmod +x integrate_test.sh && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}}
- name: Post Coverage
run: bash <(curl -s https://codecov.io/bash)
......
[submodule "samples"]
path = samples
url = git@github.com:apache/dubbo-go-samples.git
......@@ -6,12 +6,17 @@
- [Add dubbo-go-cli telnet tool](https://github.com/apache/dubbo-go/pull/818)
- [Add Prox ImplementFunc to allow override impl](https://github.com/apache/dubbo-go/pull/1019)
- [Add read configuration path from the command line when start](https://github.com/apache/dubbo-go/pull/1039)
- [Add use invoker with same ip as client first](https://github.com/apache/dubbo-go/pull/1023)
- [Add an "api way" to set general configure](https://github.com/apache/dubbo-go/pull/1020)
- [Add registry ip:port set from enviroment variable](https://github.com/apache/dubbo-go/pull/1036)
### Enhancement
- [introduce ConfigPostProcessor extension](https://github.com/apache/dubbo-go/pull/943)
- [Impl extension of two urls comparison](https://github.com/apache/dubbo-go/pull/854)
- [using event-driven to let router send signal to notify channel](https://github.com/apache/dubbo-go/pull/976)
- [lint codes](https://github.com/apache/dubbo-go/pull/941)
- [Imp: destroy invoker smoothly](https://github.com/apache/dubbo-go/pull/1045)
- [Improve config center](https://github.com/apache/dubbo-go/pull/1030)
### Bugfixes
- [Fix: generic struct2MapAll key of map keep type](https://github.com/apache/dubbo-go/pull/928)
......@@ -23,8 +28,21 @@
- [Fix: etcd exit panic](https://github.com/apache/dubbo-go/pull/1013)
- [Fix: when connect to provider fail, will occur panic](https://github.com/apache/dubbo-go/pull/1021)
- [Fix: support getty send Length, when the data transfer failed](https://github.com/apache/dubbo-go/pull/1028)
- [Fix: RPCInvocation.ServiceKey use PATH_KEY instead of INTERFACE_KEY ](https://github.com/apache/dubbo-go/pull/1078/files)
- [Fix: zk too many tcp conn](https://github.com/apache/dubbo-go/pull/1010)
- [Fix: fix zk listener func pathToKey](https://github.com/apache/dubbo-go/pull/1066)
- [Fix: graceful shutdown](https://github.com/apache/dubbo-go/pull/1007)
- [Fix: nacos service provider does not require subscribe](https://github.com/apache/dubbo-go/pull/1056)
- [Fix: key of generic map convert is more general](https://github.com/apache/dubbo-go/pull/1041)
- [Fix: body buffer too short](https://github.com/apache/dubbo-go/pull/1090)
Milestone: [https://github.com/apache/dubbo-go/milestone/7](https://github.com/apache/dubbo-go/milestone/7?closed=1)
### Dependencies
- [Bump dubbo-go-hessian2 from v1.9.0-rc1 to v1.9.1](https://github.com/apache/dubbo-go/pull/1088/files)
- [Bump github.com/nacos-group/nacos-sdk-go from 1.0.5 to v1.0.7](https://github.com/apache/dubbo-go/pull/1106)
Milestone:
- [https://github.com/apache/dubbo-go/milestone/7](https://github.com/apache/dubbo-go/milestone/7?closed=1)
- [https://github.com/apache/dubbo-go/milestone/10](https://github.com/apache/dubbo-go/milestone/10?closed=1)
## 1.5.5
......
......@@ -73,6 +73,7 @@ Finished List:
- Router
* [Condition router](https://github.com/apache/dubbo-go/pull/294)
* [Health check router](https://github.com/apache/dubbo-go/pull/389)
* [Dynamic_tag_router](https://github.com/apache/dubbo-go/pull/703)
- Registry
* ZooKeeper
......@@ -134,6 +135,10 @@ Finished List:
* [Nacos](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/nacos/service_discovery.go)
* [Zookeeper](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/zookeeper/service_discovery.go)
* [Etcd](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/etcdv3/service_discovery.go)
* [File](https://github.com/apache/dubbo-go/pull/732)
- Tool
* [Dubbo-go-cli](https://github.com/apache/dubbo-go/pull/818)
You can know more about dubbo-go by its [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap).
......@@ -177,7 +182,7 @@ If you are willing to do some code contributions and document contributions to [
## Community
If u want to communicate with our community, pls scan the following [dubbobo Ding-Ding QR code](https://mmbiz.qpic.cn/mmbiz_jpg/yvBJb5IiafvnHVBdtia30dxA2hKotr9DEckWsZ7aOJcDWDaSVMGwLmYv8GRgIQtqb4C2svicp8nVkMmGy7yKC5tyA/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1) or search our commnity DingDing group code 31363295.
If u want to communicate with our community, pls scan the following dubbobo Ding-Ding QR code or search our commnity DingDing group code 31363295.
<div>
<table>
......
......@@ -72,6 +72,7 @@ Apache License, Version 2.0
- 路由器
* [Condition router](https://github.com/apache/dubbo-go/pull/294)
* [Health check router](https://github.com/apache/dubbo-go/pull/389)
* [Dynamic_tag_router](https://github.com/apache/dubbo-go/pull/703)
- 注册中心
* ZooKeeper
......@@ -133,6 +134,10 @@ Apache License, Version 2.0
* [Nacos](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/nacos/service_discovery.go)
* [Zookeeper](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/zookeeper/service_discovery.go)
* [Etcd](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/etcdv3/service_discovery.go)
* [File](https://github.com/apache/dubbo-go/pull/732)
- 工具箱
* [Dubbo-go-cli](https://github.com/apache/dubbo-go/pull/818)
你可以通过访问 [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap) 知道更多关于 dubbo-go 的信息。
......@@ -194,7 +199,22 @@ make test
</table>
</div>
如果想加入到社区微信群,可以先添加社区负责人 于雨 的微信 AlexanderStocks 。添加微信之前,请先给 dubbo-go 点 star 作为对项目的支持,添加好友时请报上 github ID 以进行验证。
dubbogo 社区已经开通微信公众号 "dubbogo大区",可在微信搜索 "dubbogo大区" 或者扫描如下二维码关注,可通过公众号私信留言加入 dubbogo 微信社区。
<div>
<table>
<tbody>
<tr></tr>
<tr>
<td align="center" valign="middle">
<img width="80px" height="115px" src="./doc/pic/misc/dubbogo-wechat.png">
</a>
</td>
</tr>
<tr></tr>
</tbody>
</table>
</div>
作为一个维护已经帮助构建了经受多家大型微服务系统的社区,我们足以为现有的成绩感到自豪。社区欢迎能提出建设性意见者,只知索取者和喷子请绕行。
......
......@@ -25,6 +25,8 @@ import (
)
import (
zk "github.com/dubbogo/go-zookeeper/zk"
gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
)
......@@ -38,7 +40,6 @@ import (
_ "github.com/apache/dubbo-go/config_center/zookeeper"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
"github.com/apache/dubbo-go/remoting/zookeeper"
)
const (
......@@ -53,16 +54,19 @@ const (
consumerFormat = "consumer://%s/com.foo.BarService"
dubboForamt = "dubbo://%s:%d/com.foo.BarService"
anyUrlFormat = "condition://%s/com.foo.BarService"
zk = "zookeeper"
zkName = "zookeeper"
applicationKey = "test-condition"
applicationField = "application"
forceField = "force"
forceValue = "true"
)
var zkCluster *zk.TestCluster
func TestNewRouterChain(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
zkCluster = ts
err = z.Create(path)
assert.NoError(t, err)
testyml := `scope: application
......@@ -77,12 +81,12 @@ conditions:
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
_ = ts.Stop()
z.Delete(path)
z.Close()
}()
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
assert.Nil(t, err)
......@@ -114,7 +118,7 @@ func TestNewRouterChainURLNil(t *testing.T) {
}
func TestRouterChainAddRouters(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
_, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, gxzookeeper.WithTestCluster(zkCluster))
assert.NoError(t, err)
err = z.Create(path)
assert.NoError(t, err)
......@@ -131,13 +135,12 @@ conditions:
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
_ = ts.Stop()
assert.NoError(t, err)
z.Delete(path)
z.Close()
}()
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, zkCluster.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
......@@ -164,15 +167,10 @@ conditions:
}
func TestRouterChainRoute(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
defer func() {
err = ts.Stop()
assert.NoError(t, err)
z.Close()
}()
ts, _, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, gxzookeeper.WithTestCluster(zkCluster))
assert.Nil(t, err)
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
......@@ -197,7 +195,7 @@ func TestRouterChainRoute(t *testing.T) {
}
func TestRouterChainRouteAppRouter(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, gxzookeeper.WithTestCluster(zkCluster))
assert.NoError(t, err)
err = z.Create(path)
assert.NoError(t, err)
......@@ -214,13 +212,12 @@ conditions:
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
_ = ts.Stop()
assert.NoError(t, err)
z.Delete(path)
z.Close()
}()
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
......@@ -242,7 +239,7 @@ conditions:
}
func TestRouterChainRouteNoRoute(t *testing.T) {
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, gxzookeeper.WithTestCluster(zkCluster))
assert.Nil(t, err)
defer func() {
_ = ts.Stop()
......@@ -251,7 +248,7 @@ func TestRouterChainRouteNoRoute(t *testing.T) {
}()
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
assert.Nil(t, err)
......
......@@ -24,6 +24,7 @@ import (
)
import (
gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
)
......@@ -35,7 +36,6 @@ import (
"github.com/apache/dubbo-go/config_center"
_ "github.com/apache/dubbo-go/config_center/zookeeper"
"github.com/apache/dubbo-go/remoting"
"github.com/apache/dubbo-go/remoting/zookeeper"
)
const (
......@@ -60,7 +60,7 @@ runtime: false
conditions:
- => host != 172.22.3.91
`
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
err = z.Create(routerPath)
assert.NoError(t, err)
......@@ -68,7 +68,6 @@ conditions:
_, err = z.Conn.Set(routerPath, []byte(testYML), 0)
assert.NoError(t, err)
defer func() {
err = ts.Stop()
assert.NoError(t, err)
z.Close()
}()
......@@ -116,7 +115,7 @@ conditions:
- => host != 172.22.3.91
- host = 192.168.199.208 => host = 192.168.199.208
`
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
err = z.Create(routerPath)
assert.NoError(t, err)
......@@ -124,7 +123,6 @@ conditions:
_, err = z.Conn.Set(routerPath, []byte(testYML), 0)
assert.NoError(t, err)
defer func() {
err = ts.Stop()
assert.NoError(t, err)
z.Close()
}()
......@@ -163,7 +161,7 @@ runtime: false
conditions:
- => host != 172.22.3.91
`
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
err = z.Create(routerPath)
assert.NoError(t, err)
......
......@@ -27,6 +27,7 @@ import (
import (
"github.com/RoaringBitmap/roaring"
"github.com/dubbogo/go-zookeeper/zk"
gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
......@@ -43,7 +44,6 @@ import (
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
"github.com/apache/dubbo-go/remoting"
"github.com/apache/dubbo-go/remoting/zookeeper"
)
const (
......@@ -260,7 +260,7 @@ type DynamicTagRouter struct {
//rule *RouterRule
route *tagRouter
zkClient *zookeeper.ZookeeperClient
zkClient *gxzookeeper.ZookeeperClient
testCluster *zk.TestCluster
invokers []protocol.Invoker
url *common.URL
......@@ -299,7 +299,7 @@ tags:
- name: tag3
addresses: ["127.0.0.1:20003", "127.0.0.1:20004"]
`
ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
suite.NoError(err)
err = z.Create(routerPath)
suite.NoError(err)
......@@ -334,8 +334,6 @@ tags:
func (suite *DynamicTagRouter) TearDownTest() {
suite.zkClient.Close()
err := suite.testCluster.Stop()
suite.Nil(err)
}
func (suite *DynamicTagRouter) TestDynamicTagRouterSetByIPv4() {
......
......@@ -72,6 +72,12 @@ func (env *Environment) UpdateExternalConfigMap(externalMap map[string]string) {
for k, v := range externalMap {
env.externalConfigMap.Store(k, v)
}
env.externalConfigMap.Range(func(key, value interface{}) bool {
if _, ok := externalMap[key.(string)]; !ok {
env.externalConfigMap.Delete(key)
}
return true
})
}
// UpdateAppExternalConfigMap updates env appExternalConfigMap field
......@@ -79,15 +85,21 @@ func (env *Environment) UpdateAppExternalConfigMap(externalMap map[string]string
for k, v := range externalMap {
env.appExternalConfigMap.Store(k, v)
}
env.appExternalConfigMap.Range(func(key, value interface{}) bool {
if _, ok := externalMap[key.(string)]; !ok {
env.appExternalConfigMap.Delete(key)
}
return true
})
}
// Configuration puts externalConfigMap and appExternalConfigMap into list
// List represents a doubly linked list.
func (env *Environment) Configuration() *list.List {
cfgList := list.New()
// The sequence would be: SystemConfiguration -> ExternalConfiguration -> AppExternalConfiguration -> AbstractConfig -> PropertiesConfiguration
cfgList.PushFront(newInmemoryConfiguration(&(env.externalConfigMap)))
cfgList.PushFront(newInmemoryConfiguration(&(env.appExternalConfigMap)))
// The sequence would be: SystemConfiguration -> AppExternalConfiguration -> ExternalConfiguration -> AbstractConfig -> PropertiesConfiguration
cfgList.PushBack(newInmemoryConfiguration(&(env.appExternalConfigMap)))
cfgList.PushBack(newInmemoryConfiguration(&(env.externalConfigMap)))
return cfgList
}
......
......@@ -34,6 +34,29 @@ func TestEnvironmentUpdateExternalConfigMap(t *testing.T) {
v, ok := GetEnvInstance().externalConfigMap.Load("1")
assert.True(t, ok)
assert.Equal(t, "2", v)
GetEnvInstance().UpdateExternalConfigMap(map[string]string{"a": "b"})
v, ok = GetEnvInstance().externalConfigMap.Load("a")
assert.True(t, ok)
assert.Equal(t, "b", v)
v, ok = GetEnvInstance().externalConfigMap.Load("1")
assert.False(t, ok)
assert.Equal(t, nil, v)
}
func TestEnvironmentUpdateAppExternalConfigMap(t *testing.T) {
GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{"1": "2"})
v, ok := GetEnvInstance().appExternalConfigMap.Load("1")
assert.True(t, ok)
assert.Equal(t, "2", v)
GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{"a": "b"})
v, ok = GetEnvInstance().appExternalConfigMap.Load("a")
assert.True(t, ok)
assert.Equal(t, "b", v)
v, ok = GetEnvInstance().appExternalConfigMap.Load("1")
assert.False(t, ok)
assert.Equal(t, nil, v)
}
func TestEnvironmentConfigurationAndGetProperty(t *testing.T) {
......
......@@ -19,9 +19,9 @@ package constant
const (
// Version apache/dubbo-go version
Version = "1.5.5"
Version = "1.5.6"
// Name module name
Name = "dubbogo"
// Date release date
DATE = "2021/01/05"
DATE = "2021/03/22"
)
......@@ -50,6 +50,9 @@ type BaseConfig struct {
EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"`
MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"`
fileStream *bytes.Buffer
// cache file used to store the current used configurations.
CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"`
}
// nolint
......@@ -240,7 +243,7 @@ func setFieldValue(val reflect.Value, id reflect.Value, config *config.InmemoryC
func (c *BaseConfig) fresh() {
configList := config.GetEnvInstance().Configuration()
for element := configList.Front(); element != nil; element = element.Next() {
for element := configList.Back(); element != nil; element = element.Prev() {
cfg := element.Value.(*config.InmemoryConfiguration)
c.freshInternalConfig(cfg)
}
......
......@@ -112,6 +112,7 @@ func TestRefresh(t *testing.T) {
mockMap["dubbo.shutdown.timeout"] = "12s"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{})
father := &ConsumerConfig{
Check: &[]bool{true}[0],
......@@ -144,9 +145,10 @@ func TestAppExternalRefresh(t *testing.T) {
mockMap := getMockMap()
mockMap["dubbo.reference.com.MockService.retries"] = "5"
config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap)
mockMap["dubbo.consumer.check"] = "true"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
mockMap["dubbo.consumer.check"] = "true"
config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap)
father := &ConsumerConfig{
Check: &[]bool{true}[0],
BaseConfig: BaseConfig{
......@@ -172,9 +174,9 @@ func TestAppExternalWithoutIDRefresh(t *testing.T) {
delete(mockMap, "dubbo.reference.com.MockService.MockService.retries")
mockMap["dubbo.reference.com.MockService.retries"] = "10"
config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap)
mockMap["dubbo.consumer.check"] = "true"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
mockMap["dubbo.consumer.check"] = "true"
config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap)
father := &ConsumerConfig{
Check: &[]bool{true}[0],
BaseConfig: BaseConfig{
......@@ -204,6 +206,7 @@ func TestRefreshSingleRegistry(t *testing.T) {
mockMap["dubbo.application.name"] = "dubbo"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{})
father := &ConsumerConfig{
Check: &[]bool{true}[0],
......@@ -235,6 +238,7 @@ func TestRefreshProvider(t *testing.T) {
mockMap["dubbo.protocols.jsonrpc1.port"] = "20001"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{})
father := &ProviderConfig{
BaseConfig: BaseConfig{
......
......@@ -159,11 +159,14 @@ func TestNewProviderConfig(t *testing.T) {
assert.Equal(t, v, serviceConfig)
}
assert.NotNil(t, testProviderConfig.Registries)
for k, v := range testProviderConfig.Registries {
assert.Equal(t, k, "demoConsul")
assert.Equal(t, v, defaultConsulRegistry)
if registry, ok := testProviderConfig.Registries["demoConsul"]; ok {
assert.Equal(t, registry, defaultConsulRegistry)
}
if registry, ok := testProviderConfig.Registries["demoNacos"]; ok {
assert.Equal(t, registry, defaultNacosRegistry)
}
assert.NotNil(t, testProviderConfig.Protocols)
assert.Equal(t, testProviderConfig.Protocols["dubbo"].Name, "dubbo")
assert.Equal(t, testProviderConfig.Protocols["dubbo"].Port, "20000")
......
......@@ -162,11 +162,11 @@ func (b *configCenter) prepareEnvironment(baseConfig BaseConfig, configCenterUrl
// appGroup config file
if len(appContent) != 0 {
appMapConent, err := dynamicConfig.Parser().Parse(appContent)
appMapContent, err := dynamicConfig.Parser().Parse(appContent)
if err != nil {
return perrors.WithStack(err)
}
config.GetEnvInstance().UpdateAppExternalConfigMap(appMapConent)
config.GetEnvInstance().UpdateAppExternalConfigMap(appMapContent)
}
return nil
......
......@@ -20,6 +20,7 @@ package config
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"reflect"
......@@ -38,6 +39,7 @@ import (
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
_ "github.com/apache/dubbo-go/common/observer/dispatcher"
"github.com/apache/dubbo-go/common/yaml"
"github.com/apache/dubbo-go/registry"
)
......@@ -144,6 +146,17 @@ func loadConsumerConfig() {
ref.Implement(rpcService)
}
// Write current configuration to cache file.
if consumerConfig.CacheFile != "" {
if data, err := yaml.MarshalYML(consumerConfig); err != nil {
logger.Errorf("Marshal consumer config err: %s", err.Error())
} else {
if err := ioutil.WriteFile(consumerConfig.CacheFile, data, 0666); err != nil {
logger.Errorf("Write consumer config cache file err: %s", err.Error())
}
}
}
// wait for invoker is available, if wait over default 3s, then panic
var count int
for {
......@@ -200,6 +213,17 @@ func loadProviderConfig() {
}
checkRegistries(providerConfig.Registries, providerConfig.Registry)
// Write the current configuration to cache file.
if providerConfig.CacheFile != "" {
if data, err := yaml.MarshalYML(providerConfig); err != nil {
logger.Errorf("Marshal provider config err: %s", err.Error())
} else {
if err := ioutil.WriteFile(providerConfig.CacheFile, data, 0666); err != nil {
logger.Errorf("Write provider config cache file err: %s", err.Error())
}
}
}
for key, svs := range providerConfig.Services {
rpcService := GetProviderService(key)
if rpcService == nil {
......
......@@ -43,9 +43,9 @@ const (
// ConsumerConfig is Consumer default configuration
type ConsumerConfig struct {
BaseConfig `yaml:",inline"`
configCenter
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
BaseConfig `yaml:",inline"`
configCenter `yaml:"-"`
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
// client
Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"`
ConnectTimeout time.Duration
......
......@@ -37,8 +37,8 @@ import (
// ProviderConfig is the default configuration of service provider
type ProviderConfig struct {
BaseConfig `yaml:",inline"`
configCenter
BaseConfig `yaml:",inline"`
configCenter `yaml:"-"`
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"`
Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"`
......
......@@ -46,6 +46,11 @@ func GetProviderService(name string) common.RPCService {
return proServices[name]
}
// GetAllProviderService gets all ProviderService
func GetAllProviderService() map[string]common.RPCService {
return proServices
}
// GetCallback gets CallbackResponse by @name
func GetCallback(name string) func(response common.CallbackResponse) {
service := GetConsumerService(name)
......
......@@ -24,6 +24,7 @@ import (
import (
gxset "github.com/dubbogo/gost/container/set"
gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
perrors "github.com/pkg/errors"
)
......@@ -50,7 +51,7 @@ type zookeeperDynamicConfiguration struct {
wg sync.WaitGroup
cltLock sync.Mutex
done chan struct{}
client *zookeeper.ZookeeperClient
client *gxzookeeper.ZookeeperClient
//listenerLock sync.Mutex
listener *zookeeper.ZkEventListener
......@@ -63,7 +64,7 @@ func newZookeeperDynamicConfiguration(url *common.URL) (*zookeeperDynamicConfigu
url: url,
rootPath: "/" + url.GetParam(constant.CONFIG_NAMESPACE_KEY, config_center.DEFAULT_GROUP) + "/config",
}
err := zookeeper.ValidateZookeeperClient(c, zookeeper.WithZkName(ZkClient))
err := zookeeper.ValidateZookeeperClient(c, ZkClient)
if err != nil {
logger.Errorf("zookeeper client start error ,error message is %v", err)
return nil, err
......@@ -163,11 +164,11 @@ func (c *zookeeperDynamicConfiguration) SetParser(p parser.ConfigurationParser)
c.parser = p
}
func (c *zookeeperDynamicConfiguration) ZkClient() *zookeeper.ZookeeperClient {
func (c *zookeeperDynamicConfiguration) ZkClient() *gxzookeeper.ZookeeperClient {
return c.client
}
func (c *zookeeperDynamicConfiguration) SetZkClient(client *zookeeper.ZookeeperClient) {
func (c *zookeeperDynamicConfiguration) SetZkClient(client *gxzookeeper.ZookeeperClient) {
c.client = client
}
......@@ -206,10 +207,9 @@ func (c *zookeeperDynamicConfiguration) IsAvailable() bool {
}
func (c *zookeeperDynamicConfiguration) closeConfigs() {
logger.Infof("begin to close provider zk client")
c.cltLock.Lock()
defer c.cltLock.Unlock()
logger.Infof("begin to close provider zk client")
// Close the old client first to close the tmp node
c.client.Close()
c.client = nil
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment