fix(api): missing peer name in query option (#14835)
This commit is contained in:
parent
1f62594deb
commit
2a4d420c96
|
@ -111,6 +111,9 @@ type QueryOptions struct {
|
|||
// by the Config
|
||||
Datacenter string
|
||||
|
||||
// Providing a peer name in the query option
|
||||
Peer string
|
||||
|
||||
// AllowStale allows any Consul server (non-leader) to service
|
||||
// a read. This allows for lower latency and higher throughput
|
||||
AllowStale bool
|
||||
|
@ -812,6 +815,9 @@ func (r *request) setQueryOptions(q *QueryOptions) {
|
|||
if q.Datacenter != "" {
|
||||
r.params.Set("dc", q.Datacenter)
|
||||
}
|
||||
if q.Peer != "" {
|
||||
r.params.Set("peer", q.Peer)
|
||||
}
|
||||
if q.AllowStale {
|
||||
r.params.Set("stale", "")
|
||||
}
|
||||
|
|
|
@ -763,6 +763,7 @@ func TestAPI_SetQueryOptions(t *testing.T) {
|
|||
Namespace: "operator",
|
||||
Partition: "asdf",
|
||||
Datacenter: "foo",
|
||||
Peer: "dc10",
|
||||
AllowStale: true,
|
||||
RequireConsistent: true,
|
||||
WaitIndex: 1000,
|
||||
|
@ -779,6 +780,9 @@ func TestAPI_SetQueryOptions(t *testing.T) {
|
|||
if r.params.Get("partition") != "asdf" {
|
||||
t.Fatalf("bad: %v", r.params)
|
||||
}
|
||||
if r.params.Get("peer") != "dc10" {
|
||||
t.Fatalf("bad: %v", r.params)
|
||||
}
|
||||
if r.params.Get("dc") != "foo" {
|
||||
t.Fatalf("bad: %v", r.params)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue