MCPcopy Create free account
hub / github.com/cortexproject/cortex / ParseTimeParam

Function ParseTimeParam

pkg/util/time.go:61–71  ·  view source on GitHub ↗

ParseTimeParam parses the time request parameter into an int64, milliseconds since epoch.

(r *http.Request, paramName string, defaultValue int64)

Source from the content-addressed store, hash-verified

59
60// ParseTimeParam parses the time request parameter into an int64, milliseconds since epoch.
61func ParseTimeParam(r *http.Request, paramName string, defaultValue int64) (int64, error) {
62 val := r.FormValue(paramName)
63 if val == "" {
64 val = strconv.FormatInt(defaultValue, 10)
65 }
66 result, err := ParseTime(val)
67 if err != nil {
68 return 0, errors.Wrapf(err, "Invalid time value for '%s'", paramName)
69 }
70 return result, nil
71}
72
73// DurationWithJitter returns random duration from "input - input*variance" to "input + input*variance" interval.
74func DurationWithJitter(input time.Duration, variancePerc float64) time.Duration {

Callers 3

InstantQueryHandlerMethod · 0.92
DecodeRequestMethod · 0.92
FindMinMaxTimeFunction · 0.85

Calls 1

ParseTimeFunction · 0.85

Tested by

no test coverage detected