Skip to content

Commit

Permalink
[feat]return the same ID when input the same kvDoc request
Browse files Browse the repository at this point in the history
  • Loading branch information
little-cui committed Sep 19, 2022
1 parent efeb332 commit 8f9fc86
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions server/service/kv/kv_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ package kv

import (
"context"
"crypto/sha256"
"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"
"github.com/apache/servicecomb-kie/pkg/stringutil"
"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)
Expand Down Expand Up @@ -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", sha256.Sum256([]byte(strings.Join([]string{
kv.Domain,
kv.Project,
kv.Key,
kv.LabelFormat,
}, "/"))))
kv.UpdateRevision = revision
kv.CreateRevision = revision
now := time.Now().Unix()
Expand Down

0 comments on commit 8f9fc86

Please sign in to comment.