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 2022/09/19 09:54:35 UTC

[servicecomb-kie] branch sync created (now 7efe3ed)

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

littlecui pushed a change to branch sync
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git


      at 7efe3ed  [feat]return the same ID when input the same kvDoc request

This branch includes the following new commits:

     new 7efe3ed  [feat]return the same ID when input the same kvDoc request

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[servicecomb-kie] 01/01: [feat]return the same ID when input the same kvDoc request

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a commit to branch sync
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git

commit 7efe3edfc0d13d81b47f592bee094808c741ea29
Author: little-cui <su...@qq.com>
AuthorDate: Mon Sep 19 17:53:53 2022 +0800

    [feat]return the same ID when input the same kvDoc request
---
 server/service/kv/kv_svc.go | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/server/service/kv/kv_svc.go b/server/service/kv/kv_svc.go
index 66a958b..3943888 100644
--- a/server/service/kv/kv_svc.go
+++ b/server/service/kv/kv_svc.go
@@ -19,16 +19,11 @@ package kv
 
 import (
 	"context"
+	"crypto/sha1"
 	"fmt"
+	"strings"
 	"time"
 
-	"github.com/go-chassis/cari/config"
-	"github.com/go-chassis/cari/pkg/errsvc"
-	"github.com/go-chassis/foundation/validator"
-	"github.com/go-chassis/go-chassis/v2/pkg/backends/quota"
-	"github.com/go-chassis/openlog"
-	"github.com/gofrs/uuid"
-
 	"github.com/apache/servicecomb-kie/pkg/common"
 	"github.com/apache/servicecomb-kie/pkg/concurrency"
 	"github.com/apache/servicecomb-kie/pkg/model"
@@ -36,6 +31,11 @@ import (
 	"github.com/apache/servicecomb-kie/server/datasource"
 	"github.com/apache/servicecomb-kie/server/pubsub"
 	"github.com/apache/servicecomb-kie/server/service/sync"
+	"github.com/go-chassis/cari/config"
+	"github.com/go-chassis/cari/pkg/errsvc"
+	"github.com/go-chassis/foundation/validator"
+	"github.com/go-chassis/go-chassis/v2/pkg/backends/quota"
+	"github.com/go-chassis/openlog"
 )
 
 var listSema = concurrency.NewSemaphore(concurrency.DefaultConcurrency)
@@ -131,11 +131,12 @@ func Create(ctx context.Context, kv *model.KVDoc) (*model.KVDoc, *errsvc.Error)
 }
 
 func completeKV(kv *model.KVDoc, revision int64) error {
-	id, err := uuid.NewV4()
-	if err != nil {
-		return err
-	}
-	kv.ID = id.String()
+	kv.ID = fmt.Sprintf("%x", sha1.Sum([]byte(strings.Join([]string{
+		kv.Domain,
+		kv.Project,
+		kv.Key,
+		kv.LabelFormat,
+	}, "/"))))
 	kv.UpdateRevision = revision
 	kv.CreateRevision = revision
 	now := time.Now().Unix()