I am trying to understand various functions provided by etcd election api and what they mean semantically.
In their official documentation very briefly mentioned about what each function does, and no examples are provided. For example we have methods:
func (e *Election) Campaign(ctx context.Context, val string) error
As per my understanding campaign is used to enroll node for leadership in an election, and it is blocked until that is achieved or some error occurs.
func ResumeElection(s *Session, pfx string, leaderKey string, leaderRev int64) *Election
This one I am not sure of why we need to resume election, suppose node is already a leader. Maybe my lack of understanding is due to semantics used here.
Since we have to use a common election identifier why don't just single election suffice?
Finally my use case is to run several nodes and only allow leader to make carry out some computation/updates, under what circumstances I'd have to create new elections if single election won't be enough.