cluster

package
v0.0.0-...-724c7a8 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: EUPL-1.2 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetainSnapshotCount = 2
	RaftTimeout         = 10 * time.Second
)
View Source
const (
	LeadershipPollInterval = time.Duration(500 * time.Millisecond)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Host string `json:"host,omitempty" yaml:"host,omitempty"`
	Port int    `json:"port,omitempty" yaml:"port,omitempty"`
}

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalFlag

func (a *Address) UnmarshalFlag(value string) error

type Cluster

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

func New

func New(id string, context *distributed.Context, options ...Option) (*Cluster, error)

func (*Cluster) MonitorClusterEvents

func (c *Cluster) MonitorClusterEvents(ctx context.Context) <-chan NodeState

func (*Cluster) StartRPCServer

func (c *Cluster) StartRPCServer() error

func (*Cluster) StopRPCServer

func (c *Cluster) StopRPCServer()

type NodeState

type NodeState uint8
const (
	Initial NodeState = iota
	Leader
	Follower
	Exiting
)

type Option

type Option func(*Cluster)

Option is the type for functional options.

func WithBootstrap

func WithBootstrap(value bool) Option

func WithDirectory

func WithDirectory(dir string) Option

WithDirectory specifies the directory where the Raft cluster state is stored.

func WithLogger

func WithLogger(logger logging.Logger) Option

WithLogger specifies a logger.

func WithNetAddress

func WithNetAddress(address string) Option

WithNetAddress specifies the address used in multiplexing mode both for intra-cluster communications and to expose the gRPC services.

func WithPeer

func WithPeer(peer Peer) Option

WithPeer specifies a peer to contact to join the cluster.

func WithPeers

func WithPeers(peers ...Peer) Option

WithPeers specifies the peers to contact to join the cluster.

type Peer

type Peer struct {
	ID      string  `json:"id,omitempty" yaml:"id,omitempty"`
	Address Address `json:"address,omitempty" yaml:"address,omitempty"`
}

func (Peer) String

func (p Peer) String() string

func (*Peer) UnmarshalFlag

func (p *Peer) UnmarshalFlag(value string) error

Jump to

Keyboard shortcuts

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