Resign gives up the leadership.
(ctx context.Context)
| 51 | |
| 52 | // Resign gives up the leadership. |
| 53 | func (e *Election) Resign(ctx context.Context) error { |
| 54 | if !e.status.isLeader.Load() { |
| 55 | return ErrNotALeader |
| 56 | } |
| 57 | // trigger events |
| 58 | defer e.dispatcher.Dispatch(ctx, OnStatusChanged, OnStatusChangedPayload{Status: e.status}) |
| 59 | defer e.status.isLeader.Store(false) |
| 60 | return e.driver.Resign(ctx) |
| 61 | } |
| 62 | |
| 63 | // Status returns the current status of the election. |
| 64 | func (e *Election) Status() *Status { |