MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / GetMonitorCluster

Method GetMonitorCluster

module/monitor/iml.go:1303–1329  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1301}
1302
1303func (m *imlMonitorConfig) GetMonitorCluster(ctx context.Context) ([]*monitor_dto.MonitorCluster, error) {
1304 clusters, err := m.clusterService.ListByClusters(ctx)
1305 if err != nil {
1306 return nil, err
1307 }
1308 clusterIds := utils.SliceToSlice(clusters, func(i *cluster.Cluster) string {
1309 return i.Uuid
1310 })
1311 monitorMap, err := m.monitorService.MapByCluster(ctx, clusterIds...)
1312 if err != nil {
1313 return nil, err
1314 }
1315
1316 monitorClusters := make([]*monitor_dto.MonitorCluster, 0, len(clusters))
1317 for _, c := range clusters {
1318 mc := &monitor_dto.MonitorCluster{
1319 Id: c.Uuid,
1320 Name: c.Name,
1321 }
1322 _, ok := monitorMap[c.Uuid]
1323 if ok {
1324 mc.Enable = true
1325 }
1326 monitorClusters = append(monitorClusters, mc)
1327 }
1328 return monitorClusters, nil
1329}

Callers

nothing calls this directly

Calls 2

ListByClustersMethod · 0.65
MapByClusterMethod · 0.65

Tested by

no test coverage detected