database

package
v0.0.0-...-c325cbb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ControllerNS is the namespace for the controller database.
	ControllerNS = "controller"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DBGetter

type DBGetter interface {
	// GetDB returns a TrackedDB reference 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) (TrackedDB, error)
}

DBGetter describes the ability to supply a TrackedDB reference 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(msg, stmt string, args []any, duration float64)

Log the slow query, with the given arguments.

type SlowQueryLogger

type SlowQueryLogger interface {
	// Log 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 TrackedDB

type TrackedDB interface {
	// Txn executes the input function against the tracked database,
	// within a transaction that depends on the input context.
	// Retry semantics are applied automatically based on transient failures.
	// This is the function that almost all downstream database consumers
	// should use.
	Txn(context.Context, func(context.Context, *sql.Tx) error) error

	// TxnNoRetry executes the input function against the tracked database,
	// within a transaction that depends on the input context.
	// No retries are attempted.
	TxnNoRetry(context.Context, func(context.Context, *sql.Tx) error) error

	// Err returns an error if the underlying tracked DB is in an error
	// condition. Depending on the error, determines of the tracked DB can be
	// requested again, or should be given up and thrown away.
	Err() error
}

TrackedDB defines an interface for keeping track of sql.DB. This is useful knowing if the underlying DB can be reused after an error has occurred.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL