mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-30 15:50:07 +01:00
427ce69426
While at it, move app/vmselect/bufferedwriter to lib/bufferedwriter, since it is going to be used in VictoriaLogs
35 lines
836 B
Go
35 lines
836 B
Go
package httputils
|
|
|
|
import (
|
|
"flag"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
denyPartialResponse = flag.Bool("search.denyPartialResponse", false, "Whether to deny partial responses if a part of -storageNode instances fail to perform queries; "+
|
|
"this trades availability over consistency; see also -search.maxQueryDuration")
|
|
)
|
|
|
|
// GetBool returns boolean value from the given argKey query arg.
|
|
func GetBool(r *http.Request, argKey string) bool {
|
|
argValue := r.FormValue(argKey)
|
|
switch strings.ToLower(argValue) {
|
|
case "", "0", "f", "false", "no":
|
|
return false
|
|
default:
|
|
return true
|
|
}
|
|
}
|
|
|
|
// GetDenyPartialResponse returns whether partial responses are denied.
|
|
func GetDenyPartialResponse(r *http.Request) bool {
|
|
if *denyPartialResponse {
|
|
return true
|
|
}
|
|
if r == nil {
|
|
return false
|
|
}
|
|
return GetBool(r, "deny_partial_response")
|
|
}
|