(ctx context.Context, clusterIds ...string)
| 353 | } |
| 354 | |
| 355 | func (s *imlClusterService) Nodes(ctx context.Context, clusterIds ...string) ([]*Node, error) { |
| 356 | w := make(map[string]interface{}) |
| 357 | if len(clusterIds) > 0 { |
| 358 | w["cluster"] = clusterIds |
| 359 | } |
| 360 | nodeAddrs, err := s.nodeAddressStore.List(ctx, w, "id desc") |
| 361 | if err != nil { |
| 362 | return nil, err |
| 363 | } |
| 364 | nodes, err := s.nodeStore.List(ctx, w, "id desc") |
| 365 | if err != nil { |
| 366 | return nil, err |
| 367 | } |
| 368 | |
| 369 | addrOfNode := utils.SliceToMapArray(nodeAddrs, func(i *cluster.NodeAddr) string { |
| 370 | return i.Node |
| 371 | }) |
| 372 | |
| 373 | return utils.SliceToSlice(nodes, func(i *cluster.Node) *Node { |
| 374 | addrs := utils.SliceToMapArrayO(addrOfNode[i.UUID], func(i *cluster.NodeAddr) (string, string) { |
| 375 | return i.Type, i.Addr |
| 376 | }) |
| 377 | |
| 378 | return &Node{ |
| 379 | Uuid: i.UUID, |
| 380 | Name: i.Name, |
| 381 | Cluster: i.Cluster, |
| 382 | Peer: addrs["peer"], |
| 383 | Admin: addrs["admin"], |
| 384 | Server: addrs["server"], |
| 385 | CreateTime: i.UpdateTime, |
| 386 | } |
| 387 | }), nil |
| 388 | |
| 389 | } |
| 390 | |
| 391 | func (s *imlClusterService) CountByPartition(ctx context.Context) (map[string]int, error) { |
| 392 | return s.store.Count(ctx) |
no test coverage detected