未验证 提交 cbec574f 编写于 作者: H huanggze

declare type FormatedLevelMetric explicitly

Signed-off-by: Nhuanggze <loganhuang@yunify.com>
上级 d57bcb5c
......@@ -49,6 +49,9 @@ const (
type FormatedLevelMetric struct {
MetricsLevel string `json:"metrics_level" description:"metric level, eg. cluster"`
Results []FormatedMetric `json:"results" description:"actual array of results"`
CurrentPage int `json:"page,omitempty" description:"current page returned"`
TotalPage int `json:"total_page,omitempty" description:"total number of pages"`
TotalItem int `json:"total_item,omitempty" description:"page size"`
}
type FormatedMetric struct {
......@@ -58,7 +61,7 @@ type FormatedMetric struct {
}
type FormatedMetricData struct {
Result []map[string]interface{} `json:"result" description:"result including metric labels, time points and values"`
Result []map[string]interface{} `json:"result" description:"metric data including metric metadata, time points and values"`
ResultType string `json:"resultType" description:"result type, one of matrix, vector"`
}
......
......@@ -239,19 +239,11 @@ func Page(pageNum string, limitNum string, fmtLevelMetric *FormatedLevelMetric,
allPage := int(math.Ceil(float64(maxLength) / float64(limit)))
// add page fields
return &struct {
*FormatedLevelMetric
CurrentPage int `json:"page"`
TotalPage int `json:"total_page"`
TotalItem int `json:"total_item"`
Message string `json:"msg"`
}{
FormatedLevelMetric: fmtLevelMetric,
CurrentPage: page,
TotalItem: maxLength,
TotalPage: allPage,
Message: "paged",
}
fmtLevelMetric.CurrentPage = page
fmtLevelMetric.TotalItem = maxLength
fmtLevelMetric.TotalPage = allPage
return fmtLevelMetric
}
// maybe this function is time consuming
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册