Skip to content

Commit

Permalink
improve etcd version and change create to put (#1203)
Browse files Browse the repository at this point in the history
  • Loading branch information
ztelur authored and AlexStocks committed May 16, 2021
1 parent bda9a0b commit 6b753d5
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 40 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ Finished List:
* [For grpc](https://github.com/apache/dubbo-go/pull/397)

- Metadata Center
* [Nacos](https://github.com/apache/dubbo-go/pull/522)
* [Zookeeper](https://github.com/apache/dubbo-go/pull/633)
* [Etcd](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/metadata/report/etcd/report.go)
* [Consul](https://github.com/apache/dubbo-go/pull/633)

- Service discovery
* [Zookeeper](https://github.com/apache/dubbo-go/pull/1161)
* [Nacos(Local)](https://github.com/apache/dubbo-go/pull/522)
* [Zookeeper(Local)](https://github.com/apache/dubbo-go/pull/633)
* [Etcd(Local)](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/metadata/report/etcd/report.go)
* [Consul(Local)](https://github.com/apache/dubbo-go/pull/633)
* [Zookeeper(Remoting)](https://github.com/apache/dubbo-go/pull/1161)

- Tool
* [Dubbo-go-cli](https://github.com/apache/dubbo-go/pull/818)
Expand Down
12 changes: 5 additions & 7 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,11 @@ Apache License, Version 2.0
* [For grpc](https://github.com/apache/dubbo-go/pull/397)

- 元数据中心
* [Nacos](https://github.com/apache/dubbo-go/pull/522)
* [Zookeeper](https://github.com/apache/dubbo-go/pull/633)
* [Etcd](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/metadata/report/etcd/report.go)
* [Consul](https://github.com/apache/dubbo-go/pull/633)

- 服务发现
* [Zookeeper](https://github.com/apache/dubbo-go/pull/1161)
* [Nacos(Local)](https://github.com/apache/dubbo-go/pull/522)
* [Zookeeper(Local)](https://github.com/apache/dubbo-go/pull/633)
* [Etcd(Local)](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/metadata/report/etcd/report.go)
* [Consul(Local)](https://github.com/apache/dubbo-go/pull/633)
* [Zookeeper(Remoting)](https://github.com/apache/dubbo-go/pull/1161)

- 工具箱
* [Dubbo-go-cli](https://github.com/apache/dubbo-go/pull/818)
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/creasty/defaults v1.5.1
github.com/docker/go-connections v0.4.0 // indirect
github.com/dubbogo/go-zookeeper v1.0.3
github.com/dubbogo/gost v1.11.8
github.com/dubbogo/gost v1.11.9
github.com/dubbogo/triple v1.0.0
github.com/elazarl/go-bindata-assetfs v1.0.0 // indirect
github.com/emicklei/go-restful/v3 v3.4.0
Expand Down Expand Up @@ -51,10 +51,12 @@ require (
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/zouyx/agollo/v3 v3.4.5
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
go.etcd.io/etcd/api/v3 v3.5.0-alpha.0
go.etcd.io/etcd/client/v3 v3.5.0-alpha.0
go.etcd.io/etcd/server/v3 v3.5.0-alpha.0
go.uber.org/atomic v1.7.0
go.uber.org/zap v1.16.0
google.golang.org/grpc v1.33.1
google.golang.org/grpc v1.36.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.16.9
k8s.io/apimachinery v0.16.9
Expand Down
70 changes: 57 additions & 13 deletions go.sum

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions metadata/report/etcd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ func (e *etcdMetadataReport) PublishAppMetadata(metadataIdentifier *identifier.S
// metadata including the basic info of the server, provider info, and other user custom info
func (e *etcdMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error {
key := e.getNodeKey(providerIdentifier)
return e.client.Create(key, serviceDefinitions)
return e.client.Put(key, serviceDefinitions)
}

// StoreConsumerMetadata will store the metadata
// metadata including the basic info of the server, consumer info, and other user custom info
func (e *etcdMetadataReport) StoreConsumerMetadata(consumerMetadataIdentifier *identifier.MetadataIdentifier, serviceParameterString string) error {
key := e.getNodeKey(consumerMetadataIdentifier)
return e.client.Create(key, serviceParameterString)
return e.client.Put(key, serviceParameterString)
}

// SaveServiceMetadata will store the metadata
// metadata including the basic info of the server, service info, and other user custom info
func (e *etcdMetadataReport) SaveServiceMetadata(metadataIdentifier *identifier.ServiceMetadataIdentifier, url *common.URL) error {
key := e.getNodeKey(metadataIdentifier)
return e.client.Create(key, url.String())
return e.client.Put(key, url.String())
}

// RemoveServiceMetadata will remove the service metadata
Expand All @@ -105,7 +105,7 @@ func (e *etcdMetadataReport) GetExportedURLs(metadataIdentifier *identifier.Serv
// SaveSubscribedData will convert the urlList to json array and then store it
func (e *etcdMetadataReport) SaveSubscribedData(subscriberMetadataIdentifier *identifier.SubscriberMetadataIdentifier, urls string) error {
key := e.getNodeKey(subscriberMetadataIdentifier)
return e.client.Create(key, urls)
return e.client.Put(key, urls)
}

// GetSubscribedURLs will lookup the url
Expand Down
2 changes: 1 addition & 1 deletion metadata/report/etcd/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

import (
"github.com/stretchr/testify/assert"
"go.etcd.io/etcd/embed"
"go.etcd.io/etcd/server/v3/embed"
)

import (
Expand Down
2 changes: 1 addition & 1 deletion registry/etcdv3/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
import (
"github.com/apache/dubbo-getty"
"github.com/stretchr/testify/suite"
"go.etcd.io/etcd/embed"
"go.etcd.io/etcd/server/v3/embed"
)

import (
Expand Down
2 changes: 1 addition & 1 deletion registry/etcdv3/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (r *etcdV3Registry) CreatePath(k string) error {
var tmpPath string
for _, str := range strings.Split(k, "/")[1:] {
tmpPath = path.Join(tmpPath, "/", str)
if err := r.client.Create(tmpPath, ""); err != nil {
if err := r.client.Put(tmpPath, ""); err != nil {
return perrors.WithMessagef(err, "create path %s in etcd", tmpPath)
}
}
Expand Down
4 changes: 2 additions & 2 deletions remoting/etcdv3/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
import (
gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
perrors "github.com/pkg/errors"
"go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/mvcc/mvccpb"
"go.etcd.io/etcd/api/v3/mvccpb"
clientv3 "go.etcd.io/etcd/client/v3"
)

import (
Expand Down
2 changes: 1 addition & 1 deletion remoting/etcdv3/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
import (
gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
"github.com/stretchr/testify/assert"
"go.etcd.io/etcd/embed"
"go.etcd.io/etcd/server/v3/embed"
)

import (
Expand Down

0 comments on commit 6b753d5

Please sign in to comment.