fabric: github.com/hyperledger/fabric/gossip/election Index | Files

package election

import "github.com/hyperledger/fabric/gossip/election"


Package Files

adapter.go election.go


const (
    DefStartupGracePeriod       = time.Second * 15
    DefMembershipSampleInterval = time.Second
    DefLeaderAliveThreshold     = time.Second * 10
    DefLeaderElectionDuration   = time.Second * 5

type ElectionConfig Uses

type ElectionConfig struct {
    StartupGracePeriod       time.Duration
    MembershipSampleInterval time.Duration
    LeaderAliveThreshold     time.Duration
    LeaderElectionDuration   time.Duration

type LeaderElectionAdapter Uses

type LeaderElectionAdapter interface {
    // Gossip gossips a message to other peers

    // Accept returns a channel that emits messages
    Accept() <-chan Msg

    // CreateProposalMessage
    CreateMessage(isDeclaration bool) Msg

    // Peers returns a list of peers considered alive
    Peers() []Peer

    // ReportMetrics sends a report to the metrics server about a leadership status
    ReportMetrics(isLeader bool)

LeaderElectionAdapter is used by the leader election module to send and receive messages and to get membership information

func NewAdapter Uses

func NewAdapter(gossip gossip, pkiid common.PKIidType, channel common.ChannelID,
    metrics *metrics.ElectionMetrics) LeaderElectionAdapter

NewAdapter creates new leader election adapter

type LeaderElectionService Uses

type LeaderElectionService interface {
    // IsLeader returns whether this peer is a leader or not
    IsLeader() bool

    // Stop stops the LeaderElectionService

    // Yield relinquishes the leadership until a new leader is elected,
    // or a timeout expires

LeaderElectionService is the object that runs the leader election algorithm

func NewLeaderElectionService Uses

func NewLeaderElectionService(adapter LeaderElectionAdapter, id string, callback leadershipCallback, config ElectionConfig) LeaderElectionService

NewLeaderElectionService returns a new LeaderElectionService

type Msg Uses

type Msg interface {
    // SenderID returns the ID of the peer sent the message
    SenderID() peerID
    // IsProposal returns whether this message is a leadership proposal
    IsProposal() bool
    // IsDeclaration returns whether this message is a leadership declaration
    IsDeclaration() bool

Msg describes a message sent from a remote peer

type Peer Uses

type Peer interface {
    // ID returns the ID of the peer
    ID() peerID

Peer describes a remote peer

Package election imports 11 packages (graph) and is imported by 11 packages. Updated 2019-11-26. Refresh now. Tools for package owners.