elect

package module
v0.0.0-...-842c62d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StateName = map[CandidateState]string{
	StateLeader:    "LEADER",
	StateNotLeader: "NOT_LEADER",
}

Functions

func RandDurationN

func RandDurationN(n time.Duration) time.Duration

Types

type Candidate

type Candidate struct {
	C <-chan CandidateState
	// contains filtered or unexported fields
}

func NewCandidate

func NewCandidate(ctx context.Context, ec *event.Client, numVoters int, signingKey string) *Candidate

func (*Candidate) IsLeader

func (c *Candidate) IsLeader() bool

func (*Candidate) ServeHTTP

func (c *Candidate) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Candidate) State

func (c *Candidate) State() CandidateState

func (*Candidate) Stop

func (c *Candidate) Stop()

type CandidateState

type CandidateState int
const (
	StateUndefined CandidateState = iota
	StateLeader
	StateNotLeader
)

type Voter

type Voter struct {
	// contains filtered or unexported fields
}

func NewVoter

func NewVoter(ctx context.Context, ec *event.Client, url string, signingKey string) *Voter

func (*Voter) Stop

func (v *Voter) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL