github.com/decred/dcrlnd@v0.7.6/cluster/interface.go (about)

     1  package cluster
     2  
     3  import (
     4  	"context"
     5  )
     6  
     7  const (
     8  	// EtcdLeaderElector is the id used when constructing an
     9  	// etcdLeaderElector instance through the factory.
    10  	EtcdLeaderElector = "etcd"
    11  )
    12  
    13  // LeaderElector is a general interface implementing basic leader elections
    14  // in a clustered environment.
    15  type LeaderElector interface {
    16  	// Campaign starts a run for leadership. Campaign will block until
    17  	// the caller is elected as the leader.
    18  	Campaign(ctx context.Context) error
    19  
    20  	// Resign resigns from the leader role, allowing other election members
    21  	// to take on leadership.
    22  	Resign() error
    23  
    24  	// Leader returns the leader value for the current election.
    25  	Leader(ctx context.Context) (string, error)
    26  }