cluster

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: 18 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateInternalClusterMember

func CreateInternalClusterMember(ctx context.Context, tx *sql.Tx, object InternalClusterMember) (int64, error)

CreateInternalClusterMember adds a new internal_cluster_member to the database. generator: internal_cluster_member Create

func CreateInternalTokenRecord

func CreateInternalTokenRecord(ctx context.Context, tx *sql.Tx, object InternalTokenRecord) (int64, error)

CreateInternalTokenRecord adds a new internal_token_record to the database. generator: internal_token_record Create

func DeleteInternalClusterMember

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

DeleteInternalClusterMember deletes the internal_cluster_member matching the given key parameters. generator: internal_cluster_member DeleteOne-by-Address

func DeleteInternalTokenRecord

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

DeleteInternalTokenRecord deletes the internal_token_record matching the given key parameters. generator: internal_token_record DeleteOne-by-Name

func GetCallerProject

func GetCallerProject() string

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

func GetClusterMemberAPIExtensions

func GetClusterMemberAPIExtensions(ctx context.Context, tx *sql.Tx) ([]extensions.Extensions, error)

GetClusterMemberAPIExtensions returns the API extensions from all cluster members that are not pending. This helper is non-generated to work before generated statements are loaded, as we update the API extensions.

func GetClusterMemberSchemaVersions

func GetClusterMemberSchemaVersions(ctx context.Context, tx *sql.Tx) (internalSchema []uint64, externalSchema []uint64, err error)

GetClusterMemberSchemaVersions returns the schema versions from all cluster members that are not pending. This helper is non-generated to work before generated statements are loaded, as we update the schema.

func GetInternalClusterMemberID

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

GetInternalClusterMemberID return the ID of the internal_cluster_member with the given key. generator: internal_cluster_member ID

func GetInternalTokenRecordID

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

GetInternalTokenRecordID return the ID of the internal_token_record with the given key. generator: internal_token_record ID

func InternalClusterMemberExists

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

InternalClusterMemberExists checks if a internal_cluster_member with the given key exists. generator: internal_cluster_member Exists

func InternalTokenRecordExists

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

InternalTokenRecordExists checks if a internal_token_record with the given key exists. generator: internal_token_record Exists

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 UpdateClusterMemberAPIExtensions

func UpdateClusterMemberAPIExtensions(tx *sql.Tx, apiExtensions extensions.Extensions, address string) error

UpdateClusterMemberAPIExtensions sets the API extensions for the cluster member with the given address. This helper is non-generated to work before generated statements are loaded, as we update the API extensions.

func UpdateClusterMemberSchemaVersion

func UpdateClusterMemberSchemaVersion(tx *sql.Tx, internalVersion uint64, externalVersion uint64, address string) error

UpdateClusterMemberSchemaVersion sets the schema version for the cluster member with the given address. This helper is non-generated to work before generated statements are loaded, as we update the schema.

func UpdateInternalClusterMember

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

UpdateInternalClusterMember updates the internal_cluster_member matching the given key parameters. generator: internal_cluster_member Update

Types

type InternalClusterMember

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

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

func GetInternalClusterMember

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

GetInternalClusterMember returns the internal_cluster_member with the given key. generator: internal_cluster_member GetOne

func GetInternalClusterMembers

func GetInternalClusterMembers(ctx context.Context, tx *sql.Tx, filters ...InternalClusterMemberFilter) ([]InternalClusterMember, error)

GetInternalClusterMembers returns all available internal_cluster_members. generator: internal_cluster_member GetMany

func (InternalClusterMember) ToAPI

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

type InternalClusterMemberFilter

type InternalClusterMemberFilter struct {
	Address *string
	Name    *string
}

InternalClusterMemberFilter is used for filtering queries using generated methods.

type InternalTokenRecord

type InternalTokenRecord struct {
	ID     int
	Secret string `db:"primary=yes"`
	Name   string
}

InternalTokenRecord is the database representation of a join token record.

func GetInternalTokenRecord

func GetInternalTokenRecord(ctx context.Context, tx *sql.Tx, secret string) (*InternalTokenRecord, error)

GetInternalTokenRecord returns the internal_token_record with the given key. generator: internal_token_record GetOne

func GetInternalTokenRecords

func GetInternalTokenRecords(ctx context.Context, tx *sql.Tx, filters ...InternalTokenRecordFilter) ([]InternalTokenRecord, error)

GetInternalTokenRecords returns all available internal_token_records. generator: internal_token_record GetMany

func (*InternalTokenRecord) ToAPI

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

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

type InternalTokenRecordFilter

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

InternalTokenRecordFilter 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.

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