本文整理汇总了Golang中github.com/ARGOeu/argo-web-api/app/reports.MongoInterface.GetGroupType方法的典型用法代码示例。如果您正苦于以下问题:Golang MongoInterface.GetGroupType方法的具体用法?Golang MongoInterface.GetGroupType怎么用?Golang MongoInterface.GetGroupType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ARGOeu/argo-web-api/app/reports.MongoInterface
的用法示例。
在下文中一共展示了MongoInterface.GetGroupType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createEndpointGroupResultView
func createEndpointGroupResultView(results []EndpointGroupInterface, report reports.MongoInterface, format string) ([]byte, error) {
docRoot := &root{}
prevSuperGroup := ""
prevEndpointGroup := ""
endpointGroup := &Group{}
superGroup := &SuperGroup{}
// we iterate through the results struct array
// keeping only the value of each row
for _, row := range results {
timestamp, _ := time.Parse(customForm[0], fmt.Sprint(row.Date))
//if new superGroup value does not match the previous superGroup value
//we create a new superGroup in the xml
if prevSuperGroup != row.SuperGroup {
prevSuperGroup = row.SuperGroup
superGroup = &SuperGroup{
Name: row.SuperGroup,
Type: report.GetGroupType(),
}
docRoot.Result = append(docRoot.Result, superGroup)
prevEndpointGroup = ""
}
//if new endpointGroup does not match the previous service value
//we create a new endpointGroup entry in the xml
if prevEndpointGroup != row.Name {
prevEndpointGroup = row.Name
endpointGroup = &Group{
Name: row.Name,
Type: report.GetEndpointGroupType(),
}
superGroup.Endpoints = append(superGroup.Endpoints, endpointGroup)
}
//we append the new availability values
endpointGroup.Availability = append(endpointGroup.Availability,
&Availability{
Timestamp: timestamp.Format(customForm[1]),
Availability: fmt.Sprintf("%g", row.Availability),
Reliability: fmt.Sprintf("%g", row.Reliability),
Unknown: fmt.Sprintf("%g", row.Unknown),
Uptime: fmt.Sprintf("%g", row.Up),
Downtime: fmt.Sprintf("%g", row.Down),
})
}
if strings.ToLower(format) == "application/json" {
return json.MarshalIndent(docRoot, " ", " ")
} else {
return xml.MarshalIndent(docRoot, " ", " ")
}
}