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

Method Nodes

service/cluster/cluster.go:355–389  ·  view source on GitHub ↗
(ctx context.Context, clusterIds ...string)

Source from the content-addressed store, hash-verified

353}
354
355func (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
391func (s *imlClusterService) CountByPartition(ctx context.Context) (map[string]int, error) {
392 return s.store.Count(ctx)

Callers 2

GatewayClientMethod · 0.95
UpdateAddressMethod · 0.95

Calls 1

ListMethod · 0.65

Tested by

no test coverage detected