robotLJW commented on a change in pull request #228:
URL: https://github.com/apache/servicecomb-kie/pull/228#discussion_r756791426
##########
File path: server/datasource/etcd/kv/kv_dao.go
##########
@@ -59,6 +61,100 @@ func (s *Dao) Create(ctx context.Context, kv *model.KVDoc)
(*model.KVDoc, error)
return kv, nil
}
+// CreateWithTask is used to create a task when the configuration is created
+func (s *Dao) CreateWithTask(ctx context.Context, kv *model.KVDoc, task
*model.Task) (*model.KVDoc, error) {
+ kvBytes, err := json.Marshal(kv)
+ if err != nil {
+ openlog.Error("fail to marshal kv")
+ return nil, err
+ }
+ taskBytes, err := json.Marshal(task)
+ if err != nil {
+ openlog.Error("fail to marshal task ")
+ return nil, err
+ }
+ kvOpPut := etcdadpt.OpPut(etcdadpt.WithStrKey(key.KV(kv.Domain,
kv.Project, kv.ID)), etcdadpt.WithValue(kvBytes))
+ taskOpPut := etcdadpt.OpPut(etcdadpt.WithStrKey(key.TaskKey(kv.Domain,
kv.Project, strconv.FormatInt(task.Timestamp, 10), task.TaskID)),
etcdadpt.WithValue(taskBytes))
+ resp, err := etcdadpt.Instance().TxnWithCmp(ctx,
[]etcdadpt.OpOptions{kvOpPut, taskOpPut}, nil, nil)
Review comment:
已经改成txn
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]