diff --git a/README.md b/README.md
index 8af021bb079f47939e5f3d69037906a0c0587d56..c77a0b47665db4d82064714426995834e6a778d0 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,7 @@

---
+
Apache Dubbo Go Implementation.
@@ -134,25 +135,17 @@ Finished List:
* [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)
-- Others:
- * start check
- * connecting certain provider
- * multi-protocols
- * multi-registries
- * multi-versions
- * service group
-
You can know more about dubbo-go by its [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap).

## Document
-https://dubbogo.github.io/dubbo-go-website (**Improving**)
+[dubbo-doc](http://dubbo.apache.org/zh/blog/) or [dubbo-go-doc-list](http://alexstocks.github.io/html/dubbogo.html)
## Quick Start
-[dubbo-go-samples](https://github.com/apache/dubbo-go-samples) shows how to use dubbo-go. Please read the [dubbo-samples/golang/README.md](https://github.com/apache/dubbo-go-samples/blob/master/README.md) carefully to learn how to dispose the configuration and compile the program.
+[dubbo-go-samples](https://github.com/apache/dubbo-go-samples) gives many examples to tell u how to use dubbo-go. Please read the [dubbo-samples/golang/README.md](https://github.com/apache/dubbo-go-samples/blob/master/README.md) carefully to learn how to dispose the configuration and compile the program.
## Running unit tests
@@ -182,6 +175,17 @@ Please move to [dubbo-samples/golang](https://github.com/dubbogo/dubbo-samples)
If you are willing to do some code contributions and document contributions to [Apache/dubbo-go](https://github.com/apache/dubbo-go), please visit [contribution intro](https://github.com/apache/dubbo-go/blob/master/contributing.md).
+## 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.
+
+<a href="http://alexstocks.github.io/html/dubbogo.html">
+<img src="./doc/pic/misc/dubbogo-dingding.png" height="80" width="80"></a>
+
+If u want to visit the wechat group, pls add my wechat AlexanderStocks.
+
+We welcome the friends who can give us constructing suggestions instead of known-nothing.
+
## Benchmark
Benchmark project [dubbo-go-benchmark](https://github.com/dubbogo/dubbo-go-benchmark).
@@ -259,6 +263,11 @@ If you are using [apache/dubbo-go](github.com/apache/dubbo-go) and think that it
<img width="222px" src="https://ugc.hitv.com/platform_oss/F6077F1AA82542CDBDD88FD518E6E727.png">
</a>
</td>
+ <td align="center" valign="middle">
+ <a href="http://www.dmall.com" target="_blank">
+ <img width="222px" src="https://mosn.io/images/community/duodian.png">
+ </a>
+ </td>
</tr>
<tr></tr>
</tbody>
diff --git a/README_CN.md b/README_CN.md
index 079cfa57449734f291ab5252ed86b01ac59c542c..725db288180fd64e7a8a86b1b0154a36b1f1da5e 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -133,25 +133,17 @@ Apache License, Version 2.0
* [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)
-- 其他功能支持:
- * 启动时检查
- * 服务直连
- * 多服务协议
- * 多注册中心
- * 多服务版本
- * 服务分组
-
你可以通过访问 [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap) 知道更多关于 dubbo-go 的信息。

## 文档
-https://dubbogo.github.io/dubbo-go-website (**完善中**)
+请访问 [dubbo官方文档中关于 dubbo-go 的系列文档](http://dubbo.apache.org/zh/blog/) 或 [过往dubbo-go文档列表](http://alexstocks.github.io/html/dubbogo.html)。
## 快速开始 ##
-[dubbo-samples/golang](https://github.com/dubbogo/dubbo-samples)这个项目的事例展示了如何使用 dubbo-go 。请仔细阅读 [dubbo-samples/golang/README.md](https://github.com/dubbogo/dubbo-samples/blob/master/golang/README.md) 学习如何处理配置并编译程序。
+[dubbo-samples/golang](https://github.com/apache/dubbo-go-samples)这个项目的事例展示了如何使用 dubbo-go 。请仔细阅读 [dubbo-samples/golang/README.md](https://github.com/apache/dubbo-go-samples/blob/master/README.md) 学习如何处理配置并编译程序。
## 运行单测
@@ -181,6 +173,17 @@ make test
如果您愿意给 [Apache/dubbo-go](https://github.com/apache/dubbo-go) 贡献代码或者文档,我们都热烈欢迎。具体请参考 [contribution intro](https://github.com/apache/dubbo-go/blob/master/contributing.md)。
+## 社区
+
+如果想访问官方钉钉群,请在钉钉中搜索社区群号 31363295 或者 扫描如下[二维码](https://mmbiz.qpic.cn/mmbiz_jpg/yvBJb5IiafvnHVBdtia30dxA2hKotr9DEckWsZ7aOJcDWDaSVMGwLmYv8GRgIQtqb4C2svicp8nVkMmGy7yKC5tyA/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1)。
+
+<a href="http://alexstocks.github.io/html/dubbogo.html">
+<img src="./doc/pic/misc/dubbogo-dingding.png" height="80" width="80"></a>
+
+如果想加入到社区微信群,可以先添加社区负责人 于雨 的微信 AlexanderStocks 。添加微信之前,请先给 dubbo-go 点 star 作为对项目的支持,添加好友时请报上 github ID 以进行验证。
+
+作为一个维护已经帮助构建了经受多家大型微服务系统的社区,我们足以为现有的成绩感到自豪。社区欢迎能提出建设性意见者,只知索取者和喷子请绕行。
+
## 性能测试 ##
性能测试项目是 [dubbo-go-benchmark](https://github.com/dubbogo/dubbo-go-benchmark)。
@@ -256,6 +259,11 @@ make test
<a href="http://www.mgtv.com" target="_blank">
<img width="222px" src="https://ugc.hitv.com/platform_oss/F6077F1AA82542CDBDD88FD518E6E727.png">
</a>
+ </td>
+ <td align="center" valign="middle">
+ <a href="http://www.dmall.com" target="_blank">
+ <img width="222px" src="https://mosn.io/images/community/duodian.png">
+ </a>
</td>
</tr>
<tr></tr>
diff --git a/common/constant/key.go b/common/constant/key.go
index 50aea81371bfc8b189e80f19a5c17c5d9de7ae51..0515094f285a4bf598b04e2ea1ef376325de7ac1 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -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 (
diff --git a/common/extension/metadata_service.go b/common/extension/metadata_service.go
index e35677d148eee121c3a6c018a128b5d372c6f2c7..08ddbc333e85fbfc328bec15aa76d2a588b11afb 100644
--- a/common/extension/metadata_service.go
+++ b/common/extension/metadata_service.go
@@ -26,12 +26,15 @@ import (
)
import (
+ "github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/metadata/service"
)
var (
// there will be two types: local or remote
metadataServiceInsMap = make(map[string]func() (service.MetadataService, error), 2)
+ // remoteMetadataService
+ remoteMetadataService service.MetadataService
)
// SetMetadataService will store the msType => creator pair
@@ -48,3 +51,17 @@ func GetMetadataService(msType string) (service.MetadataService, error) {
"local - github.com/apache/dubbo-go/metadata/service/inmemory, \n"+
"remote - github.com/apache/dubbo-go/metadata/service/remote", msType))
}
+
+// GetRemoteMetadataService will get a RemoteMetadataService instance
+func GetRemoteMetadataService() (service.MetadataService, error) {
+ if remoteMetadataService != nil {
+ return remoteMetadataService, nil
+ }
+ if creator, ok := metadataServiceInsMap["remote"]; ok {
+ var err error
+ remoteMetadataService, err = creator()
+ return remoteMetadataService, err
+ }
+ logger.Warn("could not find the metadata service creator for metadataType: remote")
+ return nil, perrors.New(fmt.Sprintf("could not find the metadata service creator for metadataType: remote"))
+}
diff --git a/config/reference_config.go b/config/reference_config.go
index 431ec0e2eb3c03b27cca40acd7b721cf6b8f9755..895ab9df26399c1c9a1296e44fba8a284ba2fb6c 100644
--- a/config/reference_config.go
+++ b/config/reference_config.go
@@ -167,7 +167,8 @@ func (c *ReferenceConfig) Refer(_ interface{}) {
// FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker
c.invoker = cluster.Join(directory.NewStaticDirectory(invokers))
}
-
+ // publish consumer metadata
+ publishConsumerDefinition(cfgURL)
// create proxy
if c.Async {
callback := GetCallback(c.id)
@@ -257,6 +258,12 @@ func (c *ReferenceConfig) GenericLoad(id string) {
c.Implement(genericService)
}
+func publishConsumerDefinition(url *common.URL) {
+ if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil {
+ remoteMetadataService.PublishServiceDefinition(url)
+ }
+}
+
// postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig.
func (c *ReferenceConfig) postProcessConfig(url *common.URL) {
for _, p := range extension.GetConfigPostProcessors() {
diff --git a/config/service_config.go b/config/service_config.go
index fd49390aa2b15938a8a4aa321d47ceafef4d9be9..e8523bdea7aa014836580b7ce33fe215c145289d 100644
--- a/config/service_config.go
+++ b/config/service_config.go
@@ -234,6 +234,7 @@ func (c *ServiceConfig) Export() error {
}
c.exporters = append(c.exporters, exporter)
}
+ publishServiceDefinition(ivkURL)
}
c.exported.Store(true)
return nil
@@ -347,6 +348,12 @@ func (c *ServiceConfig) GetExportedUrls() []*common.URL {
return nil
}
+func publishServiceDefinition(url *common.URL) {
+ if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil {
+ remoteMetadataService.PublishServiceDefinition(url)
+ }
+}
+
// postProcessConfig asks registered ConfigPostProcessor to post-process the current ServiceConfig.
func (c *ServiceConfig) postProcessConfig(url *common.URL) {
for _, p := range extension.GetConfigPostProcessors() {
diff --git a/doc/pic/misc/dubbogo-dingding.png b/doc/pic/misc/dubbogo-dingding.png
new file mode 100644
index 0000000000000000000000000000000000000000..dc27d4ecce94a095e2eb70f97446c76c5b8537da
Binary files /dev/null and b/doc/pic/misc/dubbogo-dingding.png differ
diff --git a/filter/filter_impl/sentinel_filter.go b/filter/filter_impl/sentinel_filter.go
index f662db35637593f4ab92a2b12e50d5a9e4305730..1de27adbac1808dbbbf8017f0119077752191d6f 100644
--- a/filter/filter_impl/sentinel_filter.go
+++ b/filter/filter_impl/sentinel_filter.go
@@ -42,6 +42,7 @@ import (
// 1. Must initialize Sentinel Go run environment,
// refer to https://github.com/alibaba/sentinel-golang/blob/master/api/init.go
// 2. Register rules for resources user want to guard
+
func init() {
extension.SetFilter(SentinelProviderFilterName, GetSentinelProviderFilter)
extension.SetFilter(SentinelConsumerFilterName, GetSentinelConsumerFilter)
diff --git a/metadata/report/delegate/delegate_report.go b/metadata/report/delegate/delegate_report.go
index f364087fdc8c2fb2a595190d7ca0d9564ac5d171..56a22de8f8e56c040260edf86859a4499f1b2f39 100644
--- a/metadata/report/delegate/delegate_report.go
+++ b/metadata/report/delegate/delegate_report.go
@@ -109,6 +109,10 @@ type MetadataReport struct {
// NewMetadataReport will create a MetadataReport with initiation
func NewMetadataReport() (*MetadataReport, error) {
url := instance.GetMetadataReportUrl()
+ if url == nil {
+ logger.Warn("the metadataReport URL is not configured, you should configure it.")
+ return nil, perrors.New("the metadataReport URL is not configured, you should configure it.")
+ }
bmr := &MetadataReport{
reportUrl: url,
syncReport: url.GetParamBool(constant.SYNC_REPORT_KEY, false),
diff --git a/metadata/service/remote/service.go b/metadata/service/remote/service.go
index d21cc88a3d31ec2920a78c608ed13a491fd6c634..bb520d3df72c369eb4022246f20bb9e9aa1bd8b8 100644
--- a/metadata/service/remote/service.go
+++ b/metadata/service/remote/service.go
@@ -116,22 +116,40 @@ func (mts *MetadataService) UnsubscribeURL(url *common.URL) error {
func (mts *MetadataService) PublishServiceDefinition(url *common.URL) error {
interfaceName := url.GetParam(constant.INTERFACE_KEY, "")
isGeneric := url.GetParamBool(constant.GENERIC_KEY, false)
- if len(interfaceName) > 0 && !isGeneric {
- sv := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey())
- sd := definition.BuildServiceDefinition(*sv, url)
+ if common.RoleType(common.PROVIDER).Role() == url.GetParam(constant.SIDE_KEY, "") {
+ if len(interfaceName) > 0 && !isGeneric {
+ sv := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey())
+ sd := definition.BuildServiceDefinition(*sv, url)
+ id := &identifier.MetadataIdentifier{
+ BaseMetadataIdentifier: identifier.BaseMetadataIdentifier{
+ ServiceInterface: interfaceName,
+ Version: url.GetParam(constant.VERSION_KEY, ""),
+ Group: url.GetParam(constant.GROUP_KEY, constant.DUBBO),
+ Side: url.GetParam(constant.SIDE_KEY, constant.PROVIDER_PROTOCOL),
+ },
+ }
+ mts.delegateReport.StoreProviderMetadata(id, sd)
+ return nil
+ }
+ logger.Errorf("publishProvider interfaceName is empty . providerUrl:%v ", url)
+ } else {
+ params := make(map[string]string, len(url.GetParams()))
+ url.RangeParams(func(key, value string) bool {
+ params[key] = value
+ return true
+ })
id := &identifier.MetadataIdentifier{
BaseMetadataIdentifier: identifier.BaseMetadataIdentifier{
ServiceInterface: interfaceName,
Version: url.GetParam(constant.VERSION_KEY, ""),
- // Group: url.GetParam(constant.GROUP_KEY, constant.SERVICE_DISCOVERY_DEFAULT_GROUP),
- Group: url.GetParam(constant.GROUP_KEY, constant.DUBBO),
- Side: url.GetParam(constant.SIDE_KEY, "provider"),
+ Group: url.GetParam(constant.GROUP_KEY, constant.DUBBO),
+ Side: url.GetParam(constant.SIDE_KEY, "consumer"),
},
}
- mts.delegateReport.StoreProviderMetadata(id, sd)
+ mts.delegateReport.StoreConsumerMetadata(id, params)
return nil
}
- logger.Errorf("publishProvider interfaceName is empty . providerUrl:%v ", url)
+
return nil
}
diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go
index ae2345e6d5c90fcfc5c4dfb5b4da07bcf1b6f43e..de68e74906ecf14330d12bfb0ae42e86648ff9e3 100644
--- a/registry/nacos/registry.go
+++ b/registry/nacos/registry.go
@@ -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
}
diff --git a/registry/nacos/registry_test.go b/registry/nacos/registry_test.go
index a852c00b14ac82ffc64206d6880c9f0e9af7aff6..b82820577144dfe98492165372a925500c20abfb 100644
--- a/registry/nacos/registry_test.go
+++ b/registry/nacos/registry_test.go
@@ -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))
diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go
index 2ca4b8015bc8dbc51a47a46c1bec0301ac961339..c97a7f7b51d2344f1a3fc0c59582e089f1e63b62 100644
--- a/registry/servicediscovery/service_discovery_registry.go
+++ b/registry/servicediscovery/service_discovery_registry.go
@@ -174,10 +174,6 @@ func (s *serviceDiscoveryRegistry) Register(url *common.URL) error {
logger.Warnf("The URL[%s] has been registry!", url.String())
}
- err = s.metaDataService.PublishServiceDefinition(url)
- if err != nil {
- return perrors.WithMessage(err, "publish the service definition failed. ")
- }
return s.serviceNameMapping.Map(url.GetParam(constant.INTERFACE_KEY, ""),
url.GetParam(constant.GROUP_KEY, ""),
url.GetParam(constant.Version, ""),