cluster

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoreClusterMemberExists

func CoreClusterMemberExists(ctx context.Context, tx *sql.Tx, name string) (bool, error)

CoreClusterMemberExists checks if a core_cluster_member with the given key exists.

func CoreTokenRecordExists

func CoreTokenRecordExists(ctx context.Context, tx *sql.Tx, secret string) (bool, error)

CoreTokenRecordExists checks if a core_token_record with the given key exists.

func CreateCoreClusterMember

func CreateCoreClusterMember(ctx context.Context, tx *sql.Tx, object CoreClusterMember) (int64, error)

CreateCoreClusterMember adds a new core_cluster_member to the database.

func CreateCoreTokenRecord

func CreateCoreTokenRecord(ctx context.Context, tx *sql.Tx, object CoreTokenRecord) (int64, error)

CreateCoreTokenRecord adds a new core_token_record to the database.

func DeleteCoreClusterMember

func DeleteCoreClusterMember(ctx context.Context, tx *sql.Tx, address string) error

DeleteCoreClusterMember deletes the core_cluster_member matching the given key parameters.

func DeleteCoreTokenRecord

func DeleteCoreTokenRecord(ctx context.Context, tx *sql.Tx, name string) error

DeleteCoreTokenRecord deletes the core_token_record matching the given key parameters.

func DeleteExpiredCoreTokenRecords

func DeleteExpiredCoreTokenRecords(ctx context.Context, tx *sql.Tx) error

DeleteExpiredCoreTokenRecords cleans up expired tokens.

func GetCoreClusterMemberID

func GetCoreClusterMemberID(ctx context.Context, tx *sql.Tx, name string) (int64, error)

GetCoreClusterMemberID return the ID of the core_cluster_member with the given key.

func GetCoreTokenRecordID

func GetCoreTokenRecordID(ctx context.Context, tx *sql.Tx, secret string) (int64, error)

GetCoreTokenRecordID return the ID of the core_token_record with the given key.

func UpdateCoreClusterMember

func UpdateCoreClusterMember(ctx context.Context, tx *sql.Tx, name string, object CoreClusterMember) error

UpdateCoreClusterMember updates the core_cluster_member matching the given key parameters.

Types

type CoreClusterMember

type CoreClusterMember struct {
	ID             int
	Name           string `db:"primary=yes"`
	Address        string
	Certificate    string
	SchemaInternal uint64
	SchemaExternal uint64
	APIExtensions  types.Extensions
	Heartbeat      time.Time
	Role           Role
}

CoreClusterMember represents the global database entry for a dqlite cluster member.

func GetCoreClusterMember

func GetCoreClusterMember(ctx context.Context, tx *sql.Tx, name string) (*CoreClusterMember, error)

GetCoreClusterMember returns the core_cluster_member with the given key.

func GetCoreClusterMembers

func GetCoreClusterMembers(ctx context.Context, tx *sql.Tx, filters ...CoreClusterMemberFilter) ([]CoreClusterMember, error)

GetCoreClusterMembers returns all available core_cluster_members.

func GetUpgradingClusterMembers

func GetUpgradingClusterMembers(ctx context.Context, tx *sql.Tx, schemaInternal uint64, schemaExternal uint64, apiExtensions types.Extensions) (allMembers []CoreClusterMember, awaitingMembers map[string]bool, err error)

GetUpgradingClusterMembers returns the list of all cluster members during an upgrade, as well as a map of members who we consider to be in a waiting state. This function can be used immediately after dqlite is ready, before we have loaded any prepared statements. A cluster member will be in a waiting state if a different cluster member still exists with a smaller API extension count or schema version.

func (CoreClusterMember) ToAPI

ToAPI returns the api struct for a ClusterMember database entity. The cluster member's status will be reported as unreachable by default.

type CoreClusterMemberFilter

type CoreClusterMemberFilter struct {
	Address *string
	Name    *string
}

CoreClusterMemberFilter is used for filtering queries using generated methods.

type CoreTokenRecord

type CoreTokenRecord struct {
	ID         int
	Secret     string `db:"primary=yes"`
	Name       string
	ExpiryDate sql.NullTime
}

CoreTokenRecord is the database representation of a join token record.

func GetCoreTokenRecord

func GetCoreTokenRecord(ctx context.Context, tx *sql.Tx, secret string) (*CoreTokenRecord, error)

GetCoreTokenRecord returns the core_token_record with the given key.

func GetCoreTokenRecords

func GetCoreTokenRecords(ctx context.Context, tx *sql.Tx, filters ...CoreTokenRecordFilter) ([]CoreTokenRecord, error)

GetCoreTokenRecords returns all available core_token_records.

func (*CoreTokenRecord) Expired

func (t *CoreTokenRecord) Expired() bool

Expired compares the token's expiry date with the current time.

func (*CoreTokenRecord) ToAPI

func (t *CoreTokenRecord) ToAPI(clusterCert *x509.Certificate, joinAddresses []types.AddrPort) (*types.TokenRecord, error)

ToAPI converts the CoreTokenRecord to a full token and returns an API compatible struct.

type CoreTokenRecordFilter

type CoreTokenRecordFilter struct {
	ID     *int
	Secret *string
	Name   *string
}

CoreTokenRecordFilter is the filter struct for filtering results from generated methods.

type Role

type Role string

Role is the role of the dqlite cluster member.

const Pending Role = "PENDING"

Pending indicates that a node is about to be added or removed.

Jump to

Keyboard shortcuts

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