Lower-case web API method arguments.
This commit is contained in:
parent
95f8885c8a
commit
20c5ca1d72
|
@ -25,8 +25,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (serv MetricsService) Query(Expr string, Json string) (result string) {
|
func (serv MetricsService) Query(expr string, formatJson string) (result string) {
|
||||||
exprNode, err := rules.LoadExprFromString(Expr)
|
exprNode, err := rules.LoadExprFromString(expr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ast.ErrorToJSON(err)
|
return ast.ErrorToJSON(err)
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func (serv MetricsService) Query(Expr string, Json string) (result string) {
|
||||||
|
|
||||||
rb := serv.ResponseBuilder()
|
rb := serv.ResponseBuilder()
|
||||||
var format ast.OutputFormat
|
var format ast.OutputFormat
|
||||||
if Json != "" {
|
if formatJson != "" {
|
||||||
format = ast.JSON
|
format = ast.JSON
|
||||||
rb.SetContentType(gorest.Application_Json)
|
rb.SetContentType(gorest.Application_Json)
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,8 +46,8 @@ func (serv MetricsService) Query(Expr string, Json string) (result string) {
|
||||||
return ast.EvalToString(exprNode, ×tamp, format)
|
return ast.EvalToString(exprNode, ×tamp, format)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (serv MetricsService) QueryRange(Expr string, End int64, Range int64, Step int64) string {
|
func (serv MetricsService) QueryRange(expr string, end int64, duration int64, step int64) string {
|
||||||
exprNode, err := rules.LoadExprFromString(Expr)
|
exprNode, err := rules.LoadExprFromString(expr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ast.ErrorToJSON(err)
|
return ast.ErrorToJSON(err)
|
||||||
}
|
}
|
||||||
|
@ -57,26 +57,26 @@ func (serv MetricsService) QueryRange(Expr string, End int64, Range int64, Step
|
||||||
rb := serv.ResponseBuilder()
|
rb := serv.ResponseBuilder()
|
||||||
rb.SetContentType(gorest.Application_Json)
|
rb.SetContentType(gorest.Application_Json)
|
||||||
|
|
||||||
if End == 0 {
|
if end == 0 {
|
||||||
End = serv.time.Now().Unix()
|
end = serv.time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
if Step < 1 {
|
if step < 1 {
|
||||||
Step = 1
|
step = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if End-Range < 0 {
|
if end-duration < 0 {
|
||||||
Range = End
|
duration = end
|
||||||
}
|
}
|
||||||
|
|
||||||
// Align the start to step "tick" boundary.
|
// Align the start to step "tick" boundary.
|
||||||
End -= End % Step
|
end -= end % step
|
||||||
|
|
||||||
matrix := ast.EvalVectorRange(
|
matrix := ast.EvalVectorRange(
|
||||||
exprNode.(ast.VectorNode),
|
exprNode.(ast.VectorNode),
|
||||||
time.Unix(End-Range, 0),
|
time.Unix(end-duration, 0),
|
||||||
time.Unix(End, 0),
|
time.Unix(end, 0),
|
||||||
time.Duration(Step)*time.Second)
|
time.Duration(step)*time.Second)
|
||||||
|
|
||||||
sort.Sort(matrix)
|
sort.Sort(matrix)
|
||||||
return ast.TypedValueToJSON(matrix, "matrix")
|
return ast.TypedValueToJSON(matrix, "matrix")
|
||||||
|
|
Loading…
Reference in New Issue