Documentation
¶
Index ¶
Constants ¶
const ( // ErrChangeStreamDying is used to indicate to *third parties* that the // change-stream worker is dying, instead of catacomb.ErrDying, which is // unsuitable for propagating inter-worker. // This error indicates to consuming workers that their dependency has // become unmet and a restart by the dependency engine is imminent. ErrChangeStreamDying = errors.ConstError("change-stream worker is dying") // ErrEventMultiplexerDying is used to indicate to *third parties* that the // event multiplexer worker is dying, instead of catacomb.ErrDying, which // is unsuitable for propagating inter-worker. // This error indicates to consuming workers that their dependency has // become unmet and a restart by the dependency engine is imminent. ErrEventMultiplexerDying = errors.ConstError("event multiplexer worker is dying") )
const ( // ControllerNS is the namespace for the controller database. ControllerNS = "controller" // ErrDBAccessorDying is used to indicate to *third parties* that the // db-accessor worker is dying, instead of catacomb.ErrDying, which is // unsuitable for propagating inter-worker. This error indicates to // consuming workers that their dependency has become unmet and a restart by // the dependency engine is imminent. ErrDBAccessorDying = errors.ConstError("db-accessor worker is dying") // ErrDBReplAccessorDying is used to indicate to *third parties* that the // db-repl-accessor worker is dying, instead of catacomb.ErrDying, which is // unsuitable for propagating inter-worker. This error indicates to // consuming workers that their dependency has become unmet and a restart by // the dependency engine is imminent. ErrDBReplAccessorDying = errors.ConstError("db-repl-accessor worker is dying") // ErrDBDead is used to indicate that the database is dead and should no // longer be used. ErrDBDead = errors.ConstError("database is dead") // ErrDBNotFound is used to indicate that the requested database does not // exist. ErrDBNotFound = errors.ConstError("database not found") )
Variables ¶
This section is empty.
Functions ¶
func ShortNamespace ¶
ShortNamespace returns a short version of the namespace. If the namespace is the controller namespace, then it returns the controller namespace. Otherwise, it returns a short version of the model UUID.
Types ¶
type ClusterDescriber ¶
type ClusterDescriber interface {
// ClusterDetails returns the node information for
// Dqlite nodes configured to be in the cluster.
ClusterDetails(context.Context) ([]ClusterNodeInfo, error)
}
ClusterDescriber describes the ability to get cluster details.
type ClusterNodeInfo ¶
ClusterNodeInfo describes a dqlite cluster node.
type DBDeleter ¶
type DBDeleter interface {
// DeleteDB deletes the dqlite-backed database that contains the data for
// the specified namespace.
// There are currently a set of limitations on the namespaces that can be
// deleted:
// - It is not possible to delete the controller database.
// - It currently doesn't support the actual deletion of the database
// just the removal of the worker. Deletion of the database will be
// handled once it's supported by dqlite.
DeleteDB(namespace string) error
}
DBDeleter describes the ability to delete a database.
type DBGetter ¶
type DBGetter interface {
// GetDB returns a TransactionRunner for the dqlite-backed database
// that contains the data for the specified namespace.
// A NotFound error is returned if the worker is unaware of the
// requested DB.
GetDB(ctx context.Context, namespace string) (TxnRunner, error)
}
DBGetter describes the ability to supply a transaction runner for a particular database.
type NodeRole ¶
type NodeRole string
NodeRole describes the role of a dqlite node.
Dqlite node roles.
type NoopSlowQueryLogger ¶
type NoopSlowQueryLogger struct{}
NoopSlowQueryLogger is a logger that can be substituted for a SlowQueryLogger when slow query logging is not desired.
func (NoopSlowQueryLogger) RecordSlowQuery ¶
func (NoopSlowQueryLogger) RecordSlowQuery(string, string, []any, float64)
RecordSlowQuery logs the slow query, with the given arguments.
type SlowQueryLogger ¶
type SlowQueryLogger interface {
// RecordSlowQuery logs the slow query, with the given arguments.
RecordSlowQuery(msg, stmt string, args []any, duration float64)
}
SlowQueryLogger is a logger that can be used to log slow operations.
type TxnRunner ¶
type TxnRunner interface {
// Txn manages the application of a SQLair transaction within which the
// input function is executed. See https://github.com/canonical/sqlair.
// The input context can be used by the caller to cancel this process.
Txn(context.Context, func(context.Context, *sqlair.TX) error) error
// StdTxn manages the application of a standard library transaction within
// which the input function is executed.
// The input context can be used by the caller to cancel this process.
StdTxn(context.Context, func(context.Context, *sql.Tx) error) error
// Dying returns a channel that is closed when the database connection
// is no longer usable. This can be used to detect when the database is
// shutting down or has been closed.
Dying() <-chan struct{}
}
TxnRunner defines an interface for running transactions against a database.
type TxnRunnerFactory ¶
TxnRunnerFactory aliases a function that returns a database.TxnRunner or an error.
func NewTxnRunnerFactoryForNamespace ¶
func NewTxnRunnerFactoryForNamespace[T TxnRunner](f func(context.Context, string) (T, error), ns string) TxnRunnerFactory
NewTxnRunnerFactoryForNamespace returns a TxnRunnerFactory for the input namespaced factory function and namespace.