microcluster

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args struct {
	StateDir string

	Client *client.Client
	Proxy  func(*http.Request) (*url.URL, error)
}

Args contains options for configuring MicroCluster.

type DaemonArgs

type DaemonArgs = daemon.Args

DaemonArgs are the data needed to start a MicroCluster daemon.

type MicroCluster

type MicroCluster struct {
	FileSystem *sys.OS
	// contains filtered or unexported fields
}

MicroCluster contains some basic filesystem information for interacting with the MicroCluster daemon.

func App

func App(args Args) (*MicroCluster, error)

App returns an instance of MicroCluster with a newly initialized filesystem if one does not exist.

func (*MicroCluster) GetDqliteClusterMembers

func (m *MicroCluster) GetDqliteClusterMembers() ([]cluster.DqliteMember, error)

GetDqliteClusterMembers retrieves the current local cluster configuration (derived from the trust store & dqlite metadata); it does not query the database. This is primarily intended for modifying the cluster configuration via MicroCluster.RecoverFromQuorumLoss.

func (*MicroCluster) JoinCluster

func (m *MicroCluster) JoinCluster(ctx context.Context, name string, address string, token string, initConfig map[string]string) error

JoinCluster joins an existing cluster with a join token supplied by an existing cluster member.

func (*MicroCluster) ListJoinTokens

func (m *MicroCluster) ListJoinTokens(ctx context.Context) ([]internalTypes.TokenRecord, error)

ListJoinTokens lists all the join tokens currently available for use.

func (*MicroCluster) LocalClient

func (m *MicroCluster) LocalClient() (*client.Client, error)

LocalClient returns a client connected to the local control socket.

func (*MicroCluster) NewCluster

func (m *MicroCluster) NewCluster(ctx context.Context, name string, address string, config map[string]string) error

NewCluster bootstrapps a brand new cluster with this daemon as its only member.

func (*MicroCluster) NewJoinToken

func (m *MicroCluster) NewJoinToken(ctx context.Context, name string, expireAfter time.Duration) (string, error)

NewJoinToken creates and records a new join token containing all the necessary credentials for joining a cluster. Join tokens are tied to the server certificate of the joining node, and will be deleted once the node has joined the cluster.

func (*MicroCluster) Ready

func (m *MicroCluster) Ready(ctx context.Context) error

Ready waits for the daemon to report it has finished initial setup and is ready to be bootstrapped or join an existing cluster.

func (*MicroCluster) RecoverFromQuorumLoss

func (m *MicroCluster) RecoverFromQuorumLoss(members []cluster.DqliteMember) (string, error)

RecoverFromQuorumLoss can be used to recover database access when a quorum of members is lost and cannot be recovered (e.g. hardware failure). This function requires that:

  • All cluster members' databases are not running
  • The current member has the most up-to-date raft log (usually the member which was most recently the leader)

RecoverFromQuorumLoss will take a database backup before attempting the recovery operation.

RecoverFromQuorumLoss should be invoked _exactly once_ for the entire cluster. This function creates a gz-compressed tarball and returns its path. This tarball should be manually copied by the user to the state dir of all other cluster members.

On start, Microcluster will automatically check for & load the recovery tarball. A database backup will be taken before the load.

func (*MicroCluster) RemoteClient

func (m *MicroCluster) RemoteClient(address string) (*client.Client, error)

RemoteClient gets a client for the specified cluster member URL. The filesystem will be parsed for the cluster and server certificates.

func (*MicroCluster) RevokeJoinToken

func (m *MicroCluster) RevokeJoinToken(ctx context.Context, name string) error

RevokeJoinToken revokes the token record stored under the given name.

func (*MicroCluster) SQL

SQL performs either a GET or POST on /internal/sql with a given query. This is a useful helper for using direct SQL.

func (*MicroCluster) Start

func (m *MicroCluster) Start(ctx context.Context, daemonArgs DaemonArgs) error

Start starts up a brand new MicroCluster daemon. Only the local control socket will be available at this stage, no database exists yet. Any api or schema extensions can be applied here.

func (*MicroCluster) Status

Status returns basic status information about the cluster.

Jump to

Keyboard shortcuts

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