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
9ec34fee
Commit
9ec34fee
authored
Apr 28, 2021
by
Randy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code block format and modify comment
parent
2342ba7f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
19 deletions
+7
-19
client.go
database/kv/etcd/v3/client.go
+7
-19
No files found.
database/kv/etcd/v3/client.go
View file @
9ec34fee
...
...
@@ -326,24 +326,6 @@ func (c *Client) delete(k string) error {
return
err
}
func
(
c
*
Client
)
get
(
k
string
)
(
string
,
error
)
{
rawClient
:=
c
.
GetRawClient
()
if
rawClient
==
nil
{
return
""
,
ErrNilETCDV3Client
}
resp
,
err
:=
rawClient
.
Get
(
c
.
ctx
,
k
)
if
err
!=
nil
{
return
""
,
err
}
if
len
(
resp
.
Kvs
)
==
0
{
return
""
,
ErrKVPairNotFound
}
return
string
(
resp
.
Kvs
[
0
]
.
Value
),
nil
}
// getValAndRev get value and revision
func
(
c
*
Client
)
getValAndRev
(
k
string
)
(
string
,
int64
,
error
)
{
rawClient
:=
c
.
GetRawClient
()
...
...
@@ -494,9 +476,15 @@ func (c *Client) GetChildrenKVList(k string) ([]string, []string, error) {
return
kList
,
vList
,
perrors
.
WithMessagef
(
err
,
"get key children (key %s)"
,
k
)
}
// GetValAndRev gets value and revision by @k
func
(
c
*
Client
)
GetValAndRev
(
k
string
)
(
string
,
int64
,
error
)
{
v
,
rev
,
err
:=
c
.
getValAndRev
(
k
)
return
v
,
rev
,
perrors
.
WithMessagef
(
err
,
"get key value (key %s)"
,
k
)
}
// Get gets value by @k
func
(
c
*
Client
)
Get
(
k
string
)
(
string
,
error
)
{
v
,
err
:=
c
.
get
(
k
)
v
,
_
,
err
:=
c
.
getValAndRev
(
k
)
return
v
,
perrors
.
WithMessagef
(
err
,
"get key value (key %s)"
,
k
)
}
...
...
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