MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / ResetCluster

Method ResetCluster

module/cluster/impl.go:52–77  ·  view source on GitHub ↗
(ctx context.Context, clusterId string, address string)

Source from the content-addressed store, hash-verified

50}
51
52func (m *imlClusterModule) ResetCluster(ctx context.Context, clusterId string, address string) ([]*cluster_dto.Node, error) {
53
54 nodes, err := m.clusterService.UpdateAddress(ctx, clusterId, address)
55 if err != nil {
56 return nil, err
57 }
58 err = m.initGateway(ctx, clusterId)
59 if err != nil {
60 return nil, err
61 }
62 nodesOut := utils.SliceToSlice(nodes, func(i *cluster.Node) *cluster_dto.Node {
63 return &cluster_dto.Node{
64 Id: i.Uuid,
65 Name: i.Name,
66 Admins: i.Admin,
67 Peers: i.Peer,
68 Gateways: i.Server,
69 }
70 })
71 v, has := m.settingService.Get(ctx, setting.KeyInvokeAddress)
72 if (!has || v == "") && len(nodesOut) > 0 && len(nodesOut[0].Gateways) > 0 {
73 m.settingService.Set(ctx, setting.KeyInvokeAddress, nodesOut[0].Gateways[0], utils.UserId(ctx))
74 }
75 nodeStatus(ctx, nodesOut)
76 return nodesOut, nil
77}
78func (m *imlClusterModule) initGateway(ctx context.Context, clusterId string) error {
79 client, err := m.clusterService.GatewayClient(ctx, clusterId)
80 if err != nil {

Callers

nothing calls this directly

Calls 5

initGatewayMethod · 0.95
nodeStatusFunction · 0.85
UpdateAddressMethod · 0.65
GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected