From 35fa6e13b96a4e1559f653d4e0ffef21662eb22f Mon Sep 17 00:00:00 2001 From: Vimal K Date: Sun, 12 Aug 2018 21:29:57 +0530 Subject: [PATCH] clientv3/concurrency: Document Election API context parameter fixes #9377 --- clientv3/concurrency/election.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/clientv3/concurrency/election.go b/clientv3/concurrency/election.go index 2be782106..d44e426f4 100644 --- a/clientv3/concurrency/election.go +++ b/clientv3/concurrency/election.go @@ -55,8 +55,16 @@ func ResumeElection(s *Session, pfx string, leaderKey string, leaderRev int64) * } } -// Campaign puts a value as eligible for the election. It blocks until -// it is elected, an error occurs, or the context is cancelled. +// Campaign puts a value as eligible for the election on the prefix +// key. +// Multiple sessions can participate in the election for the +// same prefix, but only one can be the leader at a time. +// +// If the context is 'context.TODO()/context.Background()', the Campaign +// will continue to be blocked for other keys to be deleted, unless server +// returns a non-recoverable error (e.g. ErrCompacted). +// Otherwise, until the context is not cancelled or timed-out, Campaign will +// continue to be blocked until it becomes the leader. func (e *Election) Campaign(ctx context.Context, val string) error { s := e.session client := e.session.Client()