Skip to content

How to determine whether a raft node is the leader? #14265

Answered by mind1949
garan82 asked this question in Q&A
Discussion options

You must be logged in to vote

In my use case, there is some work that should only be done once and the result would be propagated to other nodes. How can I make sure that only one node does this work? I am thinking of having the leader to do it, but I dont see any doc on determining whether a raft node is the leader. Any suggestions? Thanks!

If you are using raft package, Node.Status().RaftState.RaftState == StateLeader is your choice .

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by garan82
Comment options

You must be logged in to vote
1 reply
@garan82
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants