Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gostnops
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
gostnops
Commits
a2a6f13d
Commit
a2a6f13d
authored
May 03, 2021
by
Xin.Zh
Committed by
AlexStocks
May 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update client.go
parent
b0dc0cd8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
client.go
database/kv/etcd/v3/client.go
+5
-4
No files found.
database/kv/etcd/v3/client.go
View file @
a2a6f13d
...
...
@@ -38,7 +38,7 @@ var (
// ErrKVPairNotFound not found key
ErrKVPairNotFound
=
perrors
.
New
(
"k/v pair not found"
)
// ErrKVListSizeIllegal k/v list empty or not equal size
ErrKVListSizeIllegal
=
perrors
.
New
(
"k/v List is empty or kList
size not equal to vList size
"
)
ErrKVListSizeIllegal
=
perrors
.
New
(
"k/v List is empty or kList
's size is not equal to the size of vList
"
)
// ErrCompareFail txn compare fail
ErrCompareFail
=
perrors
.
New
(
"txn compare fail"
)
// ErrRevision revision when error
...
...
@@ -69,6 +69,7 @@ func NewConfigClientWithErr(opts ...Option) (*Client, error) {
log
.
Printf
(
"new etcd client (Name{%s}, etcd addresses{%v}, Timeout{%d}) = error{%v}"
,
options
.
Name
,
options
.
Endpoints
,
options
.
Timeout
,
err
)
}
return
newClient
,
err
}
...
...
@@ -239,13 +240,13 @@ func (c *Client) create(k string, v string, opts ...clientv3.OpOption) error {
If
(
clientv3
.
Compare
(
clientv3
.
CreateRevision
(
k
),
"="
,
0
))
.
Then
(
clientv3
.
OpPut
(
k
,
v
,
opts
...
))
.
Commit
()
if
err
!=
nil
{
return
err
}
if
!
resp
.
Succeeded
{
return
ErrCompareFail
}
return
nil
}
...
...
@@ -275,13 +276,13 @@ func (c *Client) batchCreate(kList []string, vList []string, opts ...clientv3.Op
If
(
cs
...
)
.
Then
(
ops
...
)
.
Commit
()
if
err
!=
nil
{
return
err
}
if
!
resp
.
Succeeded
{
return
ErrCompareFail
}
return
nil
}
...
...
@@ -307,13 +308,13 @@ func (c *Client) updateWithRev(k string, v string, rev int64, opts ...clientv3.O
If
(
clientv3
.
Compare
(
clientv3
.
ModRevision
(
k
),
"="
,
rev
))
.
Then
(
clientv3
.
OpPut
(
k
,
v
,
opts
...
))
.
Commit
()
if
err
!=
nil
{
return
err
}
if
!
resp
.
Succeeded
{
return
ErrCompareFail
}
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment