cluster

package
v0.0.0-...-2e5113c Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cluster handles creating a cluster of local rqlite nodes and injecting faults into the cluster.

This is used for running system tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

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

func NewCluster

func NewCluster() *Cluster

func OpenCluster

func OpenCluster(numNodes uint32) (*Cluster, error)

ConnectCluster creates a new cluster with `numNodes` nodes where the first node is the leader that the other nodes join.

func RunDefaultCluster

func RunDefaultCluster() (*Cluster, error)

RunDefaultCluster runs a cluster with 3 nodes and waits for it to be healthy.

func (*Cluster) AddNode

func (c *Cluster) AddNode(node *Node)

func (*Cluster) Addrs

func (c *Cluster) Addrs() []string

func (*Cluster) Close

func (c *Cluster) Close() error

func (*Cluster) NodeAddrs

func (c *Cluster) NodeAddrs() map[uint32]string

func (*Cluster) NodeRaftAddrs

func (c *Cluster) NodeRaftAddrs() map[uint32]string

func (*Cluster) RemoveNode

func (c *Cluster) RemoveNode(id uint32)

func (*Cluster) WaitForHealthy

func (c *Cluster) WaitForHealthy(ctx context.Context) bool

WaitForHealthy waits for all nodes to return a status with a consistent view of the clusters nodes and leader.

type Node

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

func NewNode

func NewNode(path string, id uint32, opts ...NodeOption) (*Node, error)

func (*Node) APIAdvAddr

func (n *Node) APIAdvAddr() string

func (*Node) Close

func (n *Node) Close() error

func (*Node) ID

func (n *Node) ID() uint32

func (*Node) RaftAdvAddr

func (n *Node) RaftAdvAddr() string

func (*Node) Reboot

func (n *Node) Reboot(duration int64, timeout bool) error

func (*Node) Status

func (n *Node) Status(ctx context.Context) (gorqlite.Status, error)

func (*Node) WaitForAllFSM

func (n *Node) WaitForAllFSM(ctx context.Context) (int, error)

WaitForAllFSM waits until all outstanding database commands have actually been applied to the database i.e. state machine.

func (*Node) WaitForLeader

func (n *Node) WaitForLeader(ctx context.Context) (string, error)

type NodeOption

type NodeOption func(conf *nodeConfig)

NodeOption overrides the default node configuration.

func WithAPIAddr

func WithAPIAddr(addr string) NodeOption

func WithAPIAdvAddr

func WithAPIAdvAddr(addr string) NodeOption

func WithDir

func WithDir(dir string) NodeOption

func WithJoin

func WithJoin(addr string) NodeOption

WithJoin requests the node joins an existing cluster at addr.

func WithRaftAddr

func WithRaftAddr(addr string) NodeOption

func WithRaftAdvAddr

func WithRaftAdvAddr(addr string) NodeOption

func WithRaftSnapInterval

func WithRaftSnapInterval(interval string) NodeOption

func WithRaftSnapThreshold

func WithRaftSnapThreshold(threshold int) NodeOption

func WithRaftVoter

func WithRaftVoter(voter bool) NodeOption

Jump to

Keyboard shortcuts

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