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 May 15, 2021
1 parent bda9a0b commit 4cb6e44
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 26 deletions.
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 4cb6e44

Please sign in to comment.