node

package
v0.0.0-...-b4c584a Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Leader election implementation based on explore/echo algorithm. It builds a distributed spanning tree

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSnapshot

func LoadSnapshot(b64 string) *snapshot

Load compressed snapshot form

func NewLamportMutexQueue

func NewLamportMutexQueue() *lamportMutexQueue

func NewSnapshot

func NewSnapshot(h *handler, balance int, randP int) *snapshot

Types

type Extension

type Extension interface {
	// Hanlde handles messages of a specific type
	Handle(h *handler, msg *com.Message) error
	// Preflight initialised additional goroutines/communication paths
	Preflight(ctx context.Context, h *handler) error
}

func NewConsensusExtension

func NewConsensusExtension(s, m, p, aMax int) (Extension, string)

func NewControlExtension

func NewControlExtension() (Extension, string)

func NewDiscoveryExtension

func NewDiscoveryExtension() (Extension, string)

func NewDistributedBankingExtension

func NewDistributedBankingExtension() (Extension, string)

func NewRumorExtension

func NewRumorExtension() (Extension, string)

NewRumorExtension returns the rumor handler + the message type

type Handler

type Handler interface {
	Run(context.Context, chan *com.Message) error
	Register(Extension, string)
}

func New

func New(uid uint, exitFunc context.CancelFunc, neighs *neigh.Neighs) Handler

type Leader

type Leader struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewLeader

func NewLeader(msgType string, wantLeader bool) *Leader

func (*Leader) ElectionComplete

func (l *Leader) ElectionComplete() bool

func (*Leader) IsLeader

func (l *Leader) IsLeader() bool

func (*Leader) PropagateChilds

func (l *Leader) PropagateChilds(h *handler, msg *com.Message) int

PropagateChilds propagates the leader election results across the child

func (*Leader) TryHandleLeaderMessage

func (l *Leader) TryHandleLeaderMessage(h *handler, msg *com.Message) (bool, error)

Jump to

Keyboard shortcuts

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