mastership

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Election

type Election interface {
	io.Closer

	// NodeID returns the local node identifier used in the election
	NodeID() cluster.NodeID

	// PartitionID returns the mastership election partition identifier
	PartitionID() PartitionID

	// GetState returns the mastership state
	GetState() (*State, error)

	// IsMaster returns a bool indicating whether the local node is the master for the device
	IsMaster() (bool, error)

	// Watch watches the election for changes
	Watch(ch chan<- State) error
}

Election is an election for a single mastership

type Key

type Key string

Key is a mastership election key

func NewKey added in v0.6.0

func NewKey(args ...interface{}) Key

NewKey creates a new mastership election key

func (Key) Hash

func (k Key) Hash() uint32

Hash returns the mastership election key as a hash

type PartitionID

type PartitionID uint32

PartitionID is the partition identifier

type State

type State struct {
	// PartitionID is the mastership partition identifier
	PartitionID PartitionID

	// Term is the mastership term
	Term Term

	// Master is the NodeID of the master for the key
	Master cluster.NodeID

	// Replicas is the replicas for the key
	Replicas []cluster.ReplicaID
}

State contains information about a mastership term

type Store

type Store interface {
	io.Closer

	// GetElection gets the mastership election for the given key
	GetElection(key Key) (Election, error)
}

Store is the mastership store

func NewDistributedStore

func NewDistributedStore(cluster cluster.Cluster, config config.Config) (Store, error)

NewDistributedStore returns a new distributed Store

func NewLocalStore

func NewLocalStore(clusterID string, nodeID cluster.NodeID) (Store, error)

NewLocalStore returns a new local election store

type Term

type Term uint64

Term is a monotonically increasing mastership term

Jump to

Keyboard shortcuts

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