MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / refreshClusterNodes

Method refreshClusterNodes

internal/home/client.go:350–379  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

348}
349
350func (c *Client) refreshClusterNodes(ctx context.Context) (bool, error) {
351 if !c.clusterDiscoveryEnabled() {
352 return false, nil
353 }
354 if ctx == nil {
355 ctx = context.Background()
356 }
357 cmd, errClient := c.commandClient()
358 if errClient != nil {
359 return false, errClient
360 }
361 raw, errDo := cmd.Do(ctx, "CLUSTER", "NODES").Text()
362 if errDo != nil {
363 return false, errDo
364 }
365
366 nodes, errParse := parseClusterNodesPayload([]byte(raw))
367 if errParse != nil {
368 return false, errParse
369 }
370 if len(nodes) == 0 {
371 return false, nil
372 }
373
374 c.mu.Lock()
375 defer c.mu.Unlock()
376 c.clusterNodes = nodes
377 c.reconnectFailures = 0
378 return c.switchToNodeLocked(nodes[0]), nil
379}
380
381func parseClusterNodesPayload(raw []byte) ([]clusterNode, error) {
382 var envelope clusterNodesEnvelope

Calls 5

commandClientMethod · 0.95
switchToNodeLockedMethod · 0.95
parseClusterNodesPayloadFunction · 0.85
DoMethod · 0.65