You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/01/05 09:42:07 UTC

[incubator-servicecomb-service-center] branch master updated: SCB-182 Registry client option 'WithStrKey' will set the wrong key as using non-copy string function. (#244)

This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new 008dbc7  SCB-182 Registry client option 'WithStrKey' will set the wrong key as using non-copy string function. (#244)
008dbc7 is described below

commit 008dbc7f02f8128933e835debed4de6ad587b214
Author: little-cui <su...@qq.com>
AuthorDate: Fri Jan 5 17:42:05 2018 +0800

    SCB-182 Registry client option 'WithStrKey' will set the wrong key as using non-copy string function. (#244)
    
    * SCB-182 Registry client option 'WithStrKey' will set the wrong key as using non-copy string function.
    
    (cherry picked from commit 894c251)
    
    * SCB-182 Optimize log print in instances.go
---
 server/error/error.go                |  2 +-
 server/infra/registry/registry.go    | 16 +++++++---------
 server/service/util/instance_util.go |  2 +-
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/server/error/error.go b/server/error/error.go
index 391d1c4..cdad863 100644
--- a/server/error/error.go
+++ b/server/error/error.go
@@ -53,7 +53,7 @@ var errors = map[int32]string{
 	ErrUnavailableBackend: "Registry service is unavailable",
 	ErrUnavailableQuota:   "Quota service is unavailable",
 
-	ErrEndpointAlreadyExists: "Endpoint more belong to other service",
+	ErrEndpointAlreadyExists: "Endpoint is already belong to other service",
 }
 
 const (
diff --git a/server/infra/registry/registry.go b/server/infra/registry/registry.go
index d331c8e..228b4e4 100644
--- a/server/infra/registry/registry.go
+++ b/server/infra/registry/registry.go
@@ -229,9 +229,9 @@ func WithNoCache() PluginOpOption            { return func(op *PluginOp) { op.Mo
 func WithWatchCallback(f WatchCallback) PluginOpOption {
 	return func(op *PluginOp) { op.WatchCallback = f }
 }
-func WithStrKey(key string) PluginOpOption     { return WithKey(util.StringToBytesWithNoCopy(key)) }
-func WithStrEndKey(key string) PluginOpOption  { return WithEndKey(util.StringToBytesWithNoCopy(key)) }
-func WithStrValue(value string) PluginOpOption { return WithValue(util.StringToBytesWithNoCopy(value)) }
+func WithStrKey(key string) PluginOpOption     { return WithKey([]byte(key)) }
+func WithStrEndKey(key string) PluginOpOption  { return WithEndKey([]byte(key)) }
+func WithStrValue(value string) PluginOpOption { return WithValue([]byte(value)) }
 func WithOffset(i int64) PluginOpOption        { return func(op *PluginOp) { op.Offset = i } }
 func WithLimit(i int64) PluginOpOption         { return func(op *PluginOp) { op.Limit = i } }
 func WatchPrefixOpOptions(key string) []PluginOpOption {
@@ -305,12 +305,10 @@ func CmpModRev(key []byte) CompareOperation {
 func CmpVal(key []byte) CompareOperation {
 	return func(op *CompareOp) { op.Key = key; op.Type = CMP_VALUE }
 }
-func CmpStrVer(key string) CompareOperation { return CmpVer(util.StringToBytesWithNoCopy(key)) }
-func CmpStrCreateRev(key string) CompareOperation {
-	return CmpCreateRev(util.StringToBytesWithNoCopy(key))
-}
-func CmpStrModRev(key string) CompareOperation { return CmpModRev(util.StringToBytesWithNoCopy(key)) }
-func CmpStrVal(key string) CompareOperation    { return CmpVal(util.StringToBytesWithNoCopy(key)) }
+func CmpStrVer(key string) CompareOperation       { return CmpVer([]byte(key)) }
+func CmpStrCreateRev(key string) CompareOperation { return CmpCreateRev([]byte(key)) }
+func CmpStrModRev(key string) CompareOperation    { return CmpModRev([]byte(key)) }
+func CmpStrVal(key string) CompareOperation       { return CmpVal([]byte(key)) }
 func OpCmp(opt CompareOperation, result CompareResult, v interface{}) (cmp CompareOp) {
 	opt(&cmp)
 	cmp.Result = result
diff --git a/server/service/util/instance_util.go b/server/service/util/instance_util.go
index eb5351f..77e91f7 100644
--- a/server/service/util/instance_util.go
+++ b/server/service/util/instance_util.go
@@ -140,7 +140,7 @@ func CheckEndPoints(ctx context.Context, in *pb.RegisterInstanceRequest) (string
 	}
 	endpointValue := ParseEndpointValue(resp.Kvs[0].Value)
 	if in.Instance.ServiceId != endpointValue.serviceId {
-		return endpointValue.instanceId, "", fmt.Errorf("endpoints more belong to service %s", endpointValue.serviceId)
+		return endpointValue.instanceId, "", fmt.Errorf("Find the same endpoints in service %s", endpointValue.serviceId)
 	}
 	return endpointValue.instanceId, "", nil
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].