Documentation
¶
Index ¶
- Constants
- Variables
- func ClusterNodes(ctx context.Context) ([]client.NodeInfo, error)
- func IsConnPoolPoisonedError(err error) bool
- func IsContentionError(err error) bool
- func IsLocalLeader(ctx context.Context) (bool, error)
- func Open(dsn string) gorm.Dialector
- func OpenSQLDB(ctx context.Context, name string) (*sql.DB, error)
- type ClusterNode
- type Dialector
- func (dialector Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v any)
- func (dialector Dialector) ClauseBuilders() map[string]clause.ClauseBuilder
- func (dialector Dialector) DataTypeOf(field *schema.Field) string
- func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression
- func (dialector Dialector) Explain(sql string, vars ...any) string
- func (dialector Dialector) Initialize(db *gorm.DB) (err error)
- func (dialector Dialector) Migrator(db *gorm.DB) gorm.Migrator
- func (dialector Dialector) Name() string
- func (dialector Dialector) QuoteTo(writer clause.Writer, str string)
- func (dialectopr Dialector) RollbackTo(tx *gorm.DB, name string) error
- func (dialectopr Dialector) SavePoint(tx *gorm.DB, name string) error
- type Migrator
- func (m Migrator) AlterColumn(value any, name string) error
- func (m Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []any)
- func (m Migrator) CreateConstraint(value any, name string) error
- func (m Migrator) CreateIndex(value any, name string) error
- func (m Migrator) CurrentDatabase() (name string)
- func (m Migrator) DropColumn(value any, name string) error
- func (m Migrator) DropConstraint(value any, name string) error
- func (m Migrator) DropIndex(value any, name string) error
- func (m Migrator) DropTable(values ...any) error
- func (m Migrator) HasColumn(value any, name string) bool
- func (m Migrator) HasConstraint(value any, name string) bool
- func (m Migrator) HasIndex(value any, name string) bool
- func (m Migrator) HasTable(value any) bool
- func (m Migrator) RenameIndex(value any, oldName, newName string) error
- func (m *Migrator) RunWithoutForeignKey(fc func() error) error
Constants ¶
const (
// DriverName is the default driver name for dqlite.
DriverName = "dqlite"
)
Variables ¶
var (
ErrNoNativeApp = errors.New("dqlite: native app is not active")
)
Functions ¶
func ClusterNodes ¶
ClusterNodes returns the current list of nodes in the dqlite cluster.
func IsConnPoolPoisonedError ¶
IsConnPoolPoisonedError matches the narrow case where a pooled connection has been left with a stale active transaction. Distinct from IsContentionError, which also covers transient busy/locked errors that don't require active recovery (an explicit ROLLBACK on the pool to clear the leftover BEGIN).
func IsContentionError ¶
IsContentionError reports whether err is a transient dqlite/SQLite contention or connection-state error worth retrying.
This is the single source of truth for contention classification across the codebase. The bounded busy-retry helpers (internal/run, internal/worker, internal/backfill) and the global connection-pool retry in pkg/db all delegate here so the matched error strings live in exactly one place.
Two distinct classes are recognised:
- Direct contention (`database is locked`, `checkpoint in progress`, etc.): a simple retry is likely to find the database in a non-busy state. dqlite surfaces a WAL checkpoint in progress as a discrete "checkpoint in progress" error rather than SQLITE_BUSY, so it must be matched by string.
- Connection-state poisoning (`cannot start a transaction within a transaction`): a previous transaction on the same pooled connection failed mid-flight (typically because the implicit ROLLBACK after a `checkpoint in progress` itself failed) and left the connection with a still-active SQLite transaction handle. The next caller's BEGIN on that connection then fails. With multiple pooled connections, retries are likely to draw a clean one.
func IsLocalLeader ¶
IsLocalLeader reports whether this process hosts the current dqlite leader.
func OpenSQLDB ¶
OpenSQLDB opens an additional *sql.DB pool to the named database on the already-running native dqlite app. It backs a separate read pool alongside the gorm-managed (write) connection, so reads stay concurrent while writes serialize on a single-connection write pool. The native app must already be initialized — it is, once the first (write) connection has been opened.
Types ¶
type ClusterNode ¶
ClusterNode is a dqlite cluster member visible to the current native app.
type Dialector ¶
func (Dialector) ClauseBuilders ¶
func (dialector Dialector) ClauseBuilders() map[string]clause.ClauseBuilder
func (Dialector) DefaultValueOf ¶
func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression