feat: add nocache url parameter option
Signed-off-by: Scott Quinlan <scott@sitehost.co.nz>
This commit is contained in:
parent
13851e9287
commit
3e7139f3b9
|
@ -1079,6 +1079,7 @@ func (h *httpAPI) LabelValues(ctx context.Context, label string, matches []strin
|
||||||
type apiOptions struct {
|
type apiOptions struct {
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
limit uint64
|
limit uint64
|
||||||
|
nocache bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Option func(c *apiOptions)
|
type Option func(c *apiOptions)
|
||||||
|
@ -1099,6 +1100,13 @@ func WithLimit(limit uint64) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithNoCache can be used to provide an optional nocache parameter for Query and QueryRange.
|
||||||
|
func WithNoCache() Option {
|
||||||
|
return func(o *apiOptions) {
|
||||||
|
o.nocache = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func addOptionalURLParams(q url.Values, opts []Option) url.Values {
|
func addOptionalURLParams(q url.Values, opts []Option) url.Values {
|
||||||
opt := &apiOptions{}
|
opt := &apiOptions{}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
|
@ -1113,6 +1121,10 @@ func addOptionalURLParams(q url.Values, opts []Option) url.Values {
|
||||||
q.Set("limit", strconv.FormatUint(opt.limit, 10))
|
q.Set("limit", strconv.FormatUint(opt.limit, 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opt.nocache {
|
||||||
|
q.Set("nocache", "1")
|
||||||
|
}
|
||||||
|
|
||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue