MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / IsReady

Method IsReady

store/engine/raft/node.go:375–397  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

373}
374
375func (n *Node) IsReady(ctx context.Context) bool {
376 tries := 0
377 for {
378 select {
379 case <-n.shutdown:
380 return false
381 case <-time.After(200 * time.Millisecond):
382 // wait for the leader to be elected
383 if n.GetRaftLead() != raft.None {
384 return true
385 }
386
387 tries++
388 if tries >= 10 {
389 // waiting too long, just return the running status
390 n.logger.Warn("Leader not elected, return the running status")
391 return n.isRunning.Load()
392 }
393 case <-ctx.Done():
394 return false
395 }
396 }
397}
398
399func (n *Node) LeaderChange() <-chan bool {
400 return n.leaderChanged

Callers

nothing calls this directly

Implementers 1

ClusterNodestore/cluster_node.go

Calls 1

GetRaftLeadMethod · 0.95

Tested by

no test coverage detected