Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type State interface {
ClusterCert() *shared.CertInfo

// Database.
Database() db.DB
Database() types.DB

// Local truststore access.
Truststore() types.Store
Expand Down Expand Up @@ -144,7 +144,7 @@ func (s *InternalState) ClusterCert() *shared.CertInfo {
}

// Database allows access to the dqlite database.
func (s *InternalState) Database() db.DB {
func (s *InternalState) Database() types.DB {
return s.InternalDatabase
}

Expand Down
8 changes: 3 additions & 5 deletions internal/db/interface.go → microcluster/types/db.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package db
package types

import (
"context"
"database/sql"

dqliteClient "github.com/canonical/go-dqlite/v3/client"

"github.com/canonical/microcluster/v3/microcluster/types"
)

// DB exposes the internal database for use with external projects.
Expand All @@ -21,13 +19,13 @@ type DB interface {
Cluster(ctx context.Context, client *dqliteClient.Client) ([]dqliteClient.NodeInfo, error)

// Status returns the current status of the database.
Status() types.DatabaseStatus
Status() 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 types.Extensions)
SchemaVersion() (versionInternal uint64, versionExternal uint64, apiExtensions Extensions)
}