Skip to content

Commit 5d73871

Browse files
author
Scott Quinlan
committed
feat: add nocache url parameter option
1 parent 13851e9 commit 5d73871

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

api/prometheus/v1/api.go

+12
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,7 @@ func (h *httpAPI) LabelValues(ctx context.Context, label string, matches []strin
10791079
type apiOptions struct {
10801080
timeout time.Duration
10811081
limit uint64
1082+
nocache bool
10821083
}
10831084

10841085
type Option func(c *apiOptions)
@@ -1099,6 +1100,13 @@ func WithLimit(limit uint64) Option {
10991100
}
11001101
}
11011102

1103+
// WithNoCache can be used to provide an optional nocache parameter for Query and QueryRange.
1104+
func WithNoCache() Option {
1105+
return func(o *apiOptions) {
1106+
o.nocache = true
1107+
}
1108+
}
1109+
11021110
func addOptionalURLParams(q url.Values, opts []Option) url.Values {
11031111
opt := &apiOptions{}
11041112
for _, o := range opts {
@@ -1113,6 +1121,10 @@ func addOptionalURLParams(q url.Values, opts []Option) url.Values {
11131121
q.Set("limit", strconv.FormatUint(opt.limit, 10))
11141122
}
11151123

1124+
if opt.nocache {
1125+
q.Set("nocache", "1")
1126+
}
1127+
11161128
return q
11171129
}
11181130

0 commit comments

Comments
 (0)