Documentation ¶
Index ¶
- Constants
- type DB
- type DqliteDB
- func (db *DqliteDB) Accept(conn net.Conn)
- func (db *DqliteDB) Bootstrap(extensions extensions.Extensions, project string, addr api.URL, ...) error
- func (db *DqliteDB) Cluster(ctx context.Context, client *dqliteClient.Client) ([]dqliteClient.NodeInfo, error)
- func (db *DqliteDB) GetHeartbeatInterval() time.Duration
- func (db *DqliteDB) IsOpen(ctx context.Context) error
- func (db *DqliteDB) Join(extensions extensions.Extensions, project string, addr api.URL, ...) error
- func (db *DqliteDB) Leader(ctx context.Context) (*dqliteClient.Client, error)
- func (db *DqliteDB) NotifyUpgraded()
- func (db *DqliteDB) Open(ext extensions.Extensions, bootstrap bool, project string) error
- func (db *DqliteDB) Schema() *update.SchemaUpdate
- func (db *DqliteDB) SchemaVersion() (versionInternal uint64, versionExternal uint64, ...)
- func (db *DqliteDB) SendHeartbeat(ctx context.Context, c *internalClient.Client, ...) error
- func (db *DqliteDB) SetSchema(schemaExtensions []schema.Update, apiExtensions extensions.Extensions)
- func (db *DqliteDB) StartWithCluster(extensions extensions.Extensions, project string, addr api.URL, ...) error
- func (db *DqliteDB) Status() types.DatabaseStatus
- func (db *DqliteDB) Stop() error
- func (db *DqliteDB) Transaction(outerCtx context.Context, f func(context.Context, *sql.Tx) error) error
- func (db *DqliteDB) Update() error
Constants ¶
const ( // DefaultHeartbeatInterval is the default interval used for heartbeats and dqlite role probes. DefaultHeartbeatInterval time.Duration = time.Second * 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { // Transaction handles performing a transaction on the dqlite database. Transaction(outerCtx context.Context, f func(context.Context, *sql.Tx) error) error // Leader returns a client connected to the leader of the dqlite cluster. Leader(ctx context.Context) (*dqliteClient.Client, error) // Cluster returns information about dqlite cluster members. Cluster(ctx context.Context, client *dqliteClient.Client) ([]dqliteClient.NodeInfo, error) // Status returns the current status of the database. Status() types.DatabaseStatus // IsOpen returns nil only if the DB has been opened and the schema loaded. // Otherwise, it returns an error describing why the database is offline. // The returned error may have the http status 503, indicating that the database is in a valid but unavailable state. IsOpen(ctx context.Context) error // SchemaVersion returns the current internal and external schema version, as well as all API extensions in memory. SchemaVersion() (versionInternal uint64, versionExternal uint64, apiExtensions extensions.Extensions) }
DB exposes the internal database for use with external projects.
type DqliteDB ¶
type DqliteDB struct {
// contains filtered or unexported fields
}
DqliteDB holds all information internal to the dqlite database.
func NewDB ¶
func NewDB(ctx context.Context, serverCert func() *shared.CertInfo, clusterCert func() *shared.CertInfo, memberName func() string, os *sys.OS, heartbeatInterval time.Duration) *DqliteDB
NewDB creates an empty db struct with no dqlite connection.
func (*DqliteDB) Accept ¶
Accept sends the outbound connection through the acceptCh channel to be received by dqlite.
func (*DqliteDB) Bootstrap ¶
func (db *DqliteDB) Bootstrap(extensions extensions.Extensions, project string, addr api.URL, clusterRecord cluster.CoreClusterMember) error
Bootstrap dqlite.
func (*DqliteDB) Cluster ¶
func (db *DqliteDB) Cluster(ctx context.Context, client *dqliteClient.Client) ([]dqliteClient.NodeInfo, error)
Cluster returns information about dqlite cluster members.
func (*DqliteDB) GetHeartbeatInterval ¶
GetHeartbeatInterval returns the current database heartbeat interval.
func (*DqliteDB) IsOpen ¶
IsOpen returns nil only if the DB has been opened and the schema loaded. Otherwise, it returns an error describing why the database is offline. The returned error may have the http status 503, indicating that the database is in a valid but unavailable state.
func (*DqliteDB) Join ¶
func (db *DqliteDB) Join(extensions extensions.Extensions, project string, addr api.URL, joinAddresses ...string) error
Join a dqlite cluster with the address of a member.
func (*DqliteDB) NotifyUpgraded ¶
func (db *DqliteDB) NotifyUpgraded()
NotifyUpgraded sends a notification that we can stop waiting for a cluster member to be upgraded.
func (*DqliteDB) Open ¶
func (db *DqliteDB) Open(ext extensions.Extensions, bootstrap bool, project string) error
Open opens the dqlite database and loads the schema. Returns true if we need to wait for other nodes to catch up to our version.
func (*DqliteDB) Schema ¶
func (db *DqliteDB) Schema() *update.SchemaUpdate
Schema returns the update.SchemaUpdate for the DB.
func (*DqliteDB) SchemaVersion ¶
func (db *DqliteDB) SchemaVersion() (versionInternal uint64, versionExternal uint64, apiExtensions extensions.Extensions)
SchemaVersion returns the current internal and external schema version, as well as all API extensions in memory.
func (*DqliteDB) SendHeartbeat ¶
func (db *DqliteDB) SendHeartbeat(ctx context.Context, c *internalClient.Client, hbInfo internalTypes.HeartbeatInfo) error
SendHeartbeat initiates a new heartbeat sequence if this is a leader node.
func (*DqliteDB) SetSchema ¶
func (db *DqliteDB) SetSchema(schemaExtensions []schema.Update, apiExtensions extensions.Extensions)
SetSchema sets schema and API extensions on the DB.
func (*DqliteDB) StartWithCluster ¶
func (db *DqliteDB) StartWithCluster(extensions extensions.Extensions, project string, addr api.URL, clusterMembers map[string]types.AddrPort) error
StartWithCluster starts up dqlite and joins the cluster.
func (*DqliteDB) Status ¶
func (db *DqliteDB) Status() types.DatabaseStatus
Status returns the current status of the database.