types

package
v0.0.0-...-526a3b6 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PublicEndpoint - Internally managed APIs available without authentication.
	PublicEndpoint types.EndpointPrefix = "cluster/1.0"

	// InternalEndpoint - all endpoints restricted to trusted servers.
	InternalEndpoint types.EndpointPrefix = "cluster/internal"

	// ControlEndpoint - all endpoints available on the local unix socket.
	ControlEndpoint types.EndpointPrefix = "cluster/control"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterMember

type ClusterMember struct {
	ClusterMemberLocal
	Role                  string                `json:"role" yaml:"role"`
	SchemaInternalVersion uint64                `json:"schema_internal_version" yaml:"schema_internal_version"`
	SchemaExternalVersion uint64                `json:"schema_external_version" yaml:"schema_external_version"`
	LastHeartbeat         time.Time             `json:"last_heartbeat" yaml:"last_heartbeat"`
	Status                MemberStatus          `json:"status" yaml:"status"`
	Extensions            extensions.Extensions `json:"extensions" yaml:"extensions"`
	Secret                string                `json:"secret" yaml:"secret"`
}

ClusterMember represents information about a dqlite cluster member.

type ClusterMemberLocal

type ClusterMemberLocal struct {
	Name        string                `json:"name" yaml:"name"`
	Address     types.AddrPort        `json:"address" yaml:"address"`
	Certificate types.X509Certificate `json:"certificate" yaml:"certificate"`
}

ClusterMemberLocal represents local information about a new cluster member.

type Control

type Control struct {
	Bootstrap  bool              `json:"bootstrap" yaml:"bootstrap"`
	InitConfig map[string]string `json:"config" yaml:"config"`
	JoinToken  string            `json:"join_token" yaml:"join_token"`
	Address    types.AddrPort    `json:"address" yaml:"address"`
	Name       string            `json:"name" yaml:"name"`
}

Control represents the arguments that can be used to initialize/shutdown the daemon.

type HeartbeatInfo

type HeartbeatInfo struct {
	BeginRound        bool                     `json:"begin_round" yaml:"begin_round"`
	MaxSchemaInternal uint64                   `json:"max_schema_internal" yaml:"max_schema_internal"`
	MaxSchemaExternal uint64                   `json:"max_schema_external" yaml:"max_schema_external"`
	ClusterMembers    map[string]ClusterMember `json:"cluster_members" yaml:"cluster_members"`
}

HeartbeatInfo represents information about the cluster sent out by the leader of the cluster to other members. If BeginRound is set, a new heartbeat will initiate.

type HookNewMemberOptions

type HookNewMemberOptions struct {
	// Name is the name of the new cluster member that joined the cluster, triggering this hook.
	Name string `json:"name" yaml:"name"`
}

HookNewMemberOptions holds configuration pertaining to the OnNewMember hook.

type HookRemoveMemberOptions

type HookRemoveMemberOptions struct {
	// Force represents whether to run the hook with the `force` option.
	Force bool `json:"force" yaml:"force"`
}

HookRemoveMemberOptions holds configuration pertaining to the PreRemove and PostRemove hooks.

type HookType

type HookType string

HookType represents the various types of hooks available to microcluster.

const (
	// OnStart is run after the daemon is started.
	OnStart HookType = "on-start"

	// PreBootstrap is run before the daemon is initialized and bootstrapped.
	PreBootstrap HookType = "pre-bootstrap"

	// PostBootstrap is run after the daemon is initialized and bootstrapped.
	PostBootstrap HookType = "post-bootstrap"

	// PreJoin is run after the daemon is initialized and joined the cluster but before existing members triggered
	// their 'OnNewMember' hooks.
	PreJoin HookType = "pre-join"

	// PostJoin is run after the daemon is initialized, joined the cluster and existing members triggered
	// their 'OnNewMember' hooks.
	PostJoin HookType = "post-join"

	// PreRemove is run on a cluster member just before it is removed from the cluster.
	PreRemove HookType = "pre-remove"

	// PostRemove is run on all other peers after one is removed from the cluster.
	PostRemove HookType = "post-remove"

	// OnNewMember is run on each peer after a new cluster member has joined and executed their 'PreJoin' hook.
	OnNewMember HookType = "on-new-member"

	// OnHeartbeat is run after a successful heartbeat round.
	OnHeartbeat HookType = "on-heartbeat"
)

type MemberStatus

type MemberStatus string

MemberStatus represents the online status of a cluster member.

const (
	// MemberOnline should be the MemberStatus when the node is online and reachable.
	MemberOnline MemberStatus = "ONLINE"

	// MemberUnreachable should be the MemberStatus when we were not able to connect to the node.
	MemberUnreachable MemberStatus = "UNREACHABLE"

	// MemberNotTrusted should be the MemberStatus when there is no local yaml entry for this node.
	MemberNotTrusted MemberStatus = "NOT TRUSTED"

	// MemberNotFound should be the MemberStatus when the node was not found in dqlite.
	MemberNotFound MemberStatus = "NOT FOUND"
)

type SQLBatch

type SQLBatch struct {
	Results []SQLResult
}

SQLBatch represents a batch of SQL results.

type SQLDump

type SQLDump struct {
	Text string `json:"text" yaml:"text"`
}

SQLDump represents the text of a SQL dump.

type SQLQuery

type SQLQuery struct {
	Query string `json:"query" yaml:"query"`
}

SQLQuery represents a SQL query.

type SQLResult

type SQLResult struct {
	Type         string   `json:"type" yaml:"type"`
	Columns      []string `json:"columns" yaml:"columns"`
	Rows         [][]any  `json:"rows" yaml:"rows"`
	RowsAffected int64    `json:"rows_affected" yaml:"rows_affected"`
}

SQLResult represents the result of executing a SQL command.

type Server

type Server struct {
	Name    string         `json:"name"    yaml:"name"`
	Address types.AddrPort `json:"address" yaml:"address"`
	Ready   bool           `json:"ready"   yaml:"ready"`
}

Server represents server status information.

type Token

type Token struct {
	// Secret is the underlying secret string used to authenticate the token.
	Secret string `json:"secret" yaml:"secret"`

	// Fingerprint is the fingerprint of the cluster certificate,
	// so that the joiner can verify that the public key of the cluster matches this request.
	Fingerprint string `json:"fingerprint" yaml:"fingerprint"`

	// JoinAddresses is the list of addresses of the existing cluster members that the joiner may supply the token to.
	// Internally, the first system to accept the token will forward it to the dqlite leader.
	JoinAddresses []types.AddrPort `json:"join_addresses" yaml:"join_addresses"`
}

Token holds the information that is presented to the joining node when requesting a token.

func DecodeToken

func DecodeToken(tokenString string) (*Token, error)

DecodeToken decodes a base64-encoded token string.

func (Token) String

func (t Token) String() (string, error)

type TokenRecord

type TokenRecord struct {
	Name  string `json:"name" yaml:"name"`
	Token string `json:"token" yaml:"token"`
}

TokenRecord holds information for requesting a join token.

type TokenResponse

type TokenResponse struct {
	// ClusterCert is the public key used across the cluster.
	ClusterCert types.X509Certificate `json:"cluster_cert" yaml:"cluster_cert"`

	// ClusterKey is the private key used across the cluster.
	ClusterKey string `json:"cluster_key" yaml:"cluster_key"`

	// ClusterMembers is the full list of cluster members that are currently present and available in the cluster.
	// The joiner supplies this list to dqlite so that it can start its database.
	ClusterMembers []ClusterMemberLocal `json:"cluster_members" yaml:"cluster_members"`

	// TrustedMember contains the address of the existing cluster member
	// who was dqlite leader at the time that the joiner supplied its join token.
	//
	// The trusted member will have already recorded the joiner's information in
	// its local truststore, and thus will trust requests from the joiner prior to fully joining.
	TrustedMember ClusterMemberLocal `json:"trusted_member" yaml:"trusted_member"`
}

TokenResponse holds the information for connecting to a cluster by a node with a valid join token.

Jump to

Keyboard shortcuts

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