MCPcopy Create free account
hub / github.com/DoNewsCode/core / Resign

Method Resign

leader/election.go:53–61  ·  view source on GitHub ↗

Resign gives up the leadership.

(ctx context.Context)

Source from the content-addressed store, hash-verified

51
52// Resign gives up the leadership.
53func (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.
64func (e *Election) Status() *Status {

Callers 2

TestElectionFunction · 0.95
TestElectionFunction · 0.95

Calls 2

DispatchMethod · 0.65
ResignMethod · 0.65

Tested by 2

TestElectionFunction · 0.76
TestElectionFunction · 0.76