mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
client: change to 'NoValueOnSuccess'
This commit is contained in:
parent
572bfd99ff
commit
fb39e96862
@ -8,10 +8,11 @@ package client
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
codec1978 "github.com/ugorji/go/codec"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
time "time"
|
time "time"
|
||||||
|
|
||||||
|
codec1978 "github.com/ugorji/go/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -192,9 +192,9 @@ type SetOptions struct {
|
|||||||
// Dir specifies whether or not this Node should be created as a directory.
|
// Dir specifies whether or not this Node should be created as a directory.
|
||||||
Dir bool
|
Dir bool
|
||||||
|
|
||||||
// NoDataOnSuccess specifies whether the response contains the current value of the Node.
|
// NoValueOnSuccess specifies whether the response contains the current value of the Node.
|
||||||
// If set, the response will only contain the current value when the request fails.
|
// If set, the response will only contain the current value when the request fails.
|
||||||
NoDataOnSuccess bool
|
NoValueOnSuccess bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetOptions struct {
|
type GetOptions struct {
|
||||||
@ -339,7 +339,7 @@ func (k *httpKeysAPI) Set(ctx context.Context, key, val string, opts *SetOptions
|
|||||||
act.TTL = opts.TTL
|
act.TTL = opts.TTL
|
||||||
act.Refresh = opts.Refresh
|
act.Refresh = opts.Refresh
|
||||||
act.Dir = opts.Dir
|
act.Dir = opts.Dir
|
||||||
act.NoDataOnSuccess = opts.NoDataOnSuccess
|
act.NoValueOnSuccess = opts.NoValueOnSuccess
|
||||||
}
|
}
|
||||||
|
|
||||||
doCtx := ctx
|
doCtx := ctx
|
||||||
@ -528,16 +528,16 @@ func (w *waitAction) HTTPRequest(ep url.URL) *http.Request {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type setAction struct {
|
type setAction struct {
|
||||||
Prefix string
|
Prefix string
|
||||||
Key string
|
Key string
|
||||||
Value string
|
Value string
|
||||||
PrevValue string
|
PrevValue string
|
||||||
PrevIndex uint64
|
PrevIndex uint64
|
||||||
PrevExist PrevExistType
|
PrevExist PrevExistType
|
||||||
TTL time.Duration
|
TTL time.Duration
|
||||||
Refresh bool
|
Refresh bool
|
||||||
Dir bool
|
Dir bool
|
||||||
NoDataOnSuccess bool
|
NoValueOnSuccess bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *setAction) HTTPRequest(ep url.URL) *http.Request {
|
func (a *setAction) HTTPRequest(ep url.URL) *http.Request {
|
||||||
@ -571,8 +571,8 @@ func (a *setAction) HTTPRequest(ep url.URL) *http.Request {
|
|||||||
if a.Refresh {
|
if a.Refresh {
|
||||||
form.Add("refresh", "true")
|
form.Add("refresh", "true")
|
||||||
}
|
}
|
||||||
if a.NoDataOnSuccess {
|
if a.NoValueOnSuccess {
|
||||||
params.Set("noDataOnSuccess", strconv.FormatBool(a.NoDataOnSuccess))
|
params.Set("noValueOnSuccess", strconv.FormatBool(a.NoValueOnSuccess))
|
||||||
}
|
}
|
||||||
|
|
||||||
u.RawQuery = params.Encode()
|
u.RawQuery = params.Encode()
|
||||||
|
@ -407,13 +407,13 @@ func TestSetAction(t *testing.T) {
|
|||||||
wantURL: "http://example.com/foo?dir=true",
|
wantURL: "http://example.com/foo?dir=true",
|
||||||
wantBody: "",
|
wantBody: "",
|
||||||
},
|
},
|
||||||
// DataOnFailure is set
|
// NoValueOnSuccess is set
|
||||||
{
|
{
|
||||||
act: setAction{
|
act: setAction{
|
||||||
Key: "foo",
|
Key: "foo",
|
||||||
NoDataOnSuccess: true,
|
NoValueOnSuccess: true,
|
||||||
},
|
},
|
||||||
wantURL: "http://example.com/foo?noDataOnSuccess=true",
|
wantURL: "http://example.com/foo?noValueOnSuccess=true",
|
||||||
wantBody: "value=",
|
wantBody: "value=",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user