clientv3/concurrency/election.go
func (e *Election) Leader(ctx context.Context) (*v3.GetResponse, error) {
	client := e.session.Client()
	resp, err := client.Get(ctx, e.keyPrefix, v3.WithFirstCreate()...)
	if err != nil {
		return nil, err
	} else if len(resp.Kvs) == 0 {
		// no leader currently elected
		return nil, ErrElectionNoLeader
	}
	return resp, nil
}
func (e *Election) Leader(ctx context.Context) (*v3.GetResponse, error) {
	client := e.session.Client()
	resp, err := client.Get(ctx, e.keyPrefix, v3.WithFirstCreate()...)
	if err != nil {
		return nil, err
	} else if len(resp.Kvs) == 0 {
		// no leader currently elected
		return nil, ErrElectionNoLeader
	}
	return resp, nil
}
func ( e * Election ) Leader ( ctx context . Context ) ( * v3 . GetResponse , error ) { client := e . session . Client ( ) resp , err := client . Get ( ctx , e . keyPrefix , v3 . WithFirstCreate ( ) ... ) if err != nil { return nil , err } else if len ( resp . Kvs ) == 0 { // no leader currently elected return nil , ErrElectionNoLeader } return resp , nil }
// Leader returns the leader value for the current election.
Leader returns the leader value for the current election .