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") // 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 ¶
This section is empty.
Types ¶
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(namespace string) (TxnRunner, error) }
DBGetter describes the ability to supply a transaction runner for a particular database.
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 }
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(string) (T, error), ns string) TxnRunnerFactory
NewTxnRunnerFactoryForNamespace returns a TxnRunnerFactory for the input namespaced factory function and namespace.