cluster

package
v0.0.0-...-4957362 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: 2

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. generator: core_cluster_member 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. generator: core_token_record 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. generator: core_cluster_member Create

func CreateCoreTokenRecord

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

CreateCoreTokenRecord adds a new core_token_record to the database. generator: core_token_record Create

func DeleteCoreClusterMember

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

DeleteCoreClusterMember deletes the core_cluster_member matching the given key parameters. generator: core_cluster_member DeleteOne-by-Address

func DeleteCoreTokenRecord

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

DeleteCoreTokenRecord deletes the core_token_record matching the given key parameters. generator: core_token_record DeleteOne-by-Name

func DeleteExpiredCoreTokenRecords

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

DeleteExpiredCoreTokenRecords cleans up expired tokens.

func GetCallerProject

func GetCallerProject() string

GetCallerProject will get the go project name of whichever function called `GetCallerProject`.

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. generator: core_cluster_member ID

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. generator: core_token_record ID

func PrepareStmts

func PrepareStmts(db *sql.DB, project string, skipErrors bool) error

PrepareStmts prepares all registered statements and stores them in preparedStmts.

func RegisterStmt

func RegisterStmt(sql string) int

RegisterStmt register a SQL statement.

Registered statements will be prepared upfront and re-used, to speed up execution.

Return a unique registration code.

func Stmt

func Stmt(tx *sql.Tx, code int) (*sql.Stmt, error)

Stmt prepares the in-memory prepared statement for the transaction.

func StmtString

func StmtString(code int) (string, error)

StmtString returns the in-memory query string with the given code.

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. generator: core_cluster_member Update

Types

type CoreClusterMember

type CoreClusterMember struct {
	ID             int
	Name           string `db:"primary=yes"`
	Address        string
	Certificate    string
	SchemaInternal uint64
	SchemaExternal uint64
	APIExtensions  extensions.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. generator: core_cluster_member GetOne

func GetCoreClusterMembers

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

GetCoreClusterMembers returns all available core_cluster_members. generator: core_cluster_member GetMany

func GetUpgradingClusterMembers

func GetUpgradingClusterMembers(ctx context.Context, tx *sql.Tx, schemaInternal uint64, schemaExternal uint64, apiExtensions extensions.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. generator: core_token_record GetOne

func GetCoreTokenRecords

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

GetCoreTokenRecords returns all available core_token_records. generator: core_token_record GetMany

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) (*internalTypes.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 DqliteMember

type DqliteMember struct {
	// dqlite.NodeInfo fields
	DqliteID uint64 `json:"id" yaml:"id"`
	Address  string `json:"address" yaml:"address"`
	Role     string `json:"role" yaml:"role"`

	Name string `json:"name" yaml:"name"`
}

DqliteMember is the information that can be derived locally about a cluster member without access to the dqlite database.

func (DqliteMember) NodeInfo

func (m DqliteMember) NodeInfo() (*dqlite.NodeInfo, error)

NodeInfo is used for interop with go-dqlite.

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.

type Schema

type Schema struct {
	ID        int
	Version   int `db:"primary=yes"`
	UpdatedAt time.Time
}

Schema represents the database schema table.

Jump to

Keyboard shortcuts

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