backend

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package backend opens the state store the configuration names, so the server and the CLIs do not each switch on the driver.

Index

Constants

View Source
const (
	DriverSQLite   = "sqlite"
	DriverPostgres = "postgres"
)

The drivers.

Variables

This section is empty.

Functions

func Backup

func Backup(ctx context.Context, o Options, out string) error

Backup writes a backup of the store o names to out, which must not exist. It never opens the store, so it works whatever the schema version.

func LockStore

func LockStore(ctx context.Context, o Options) (func() error, error)

LockStore takes the single-server lock on the store o names and returns its release. Commands that must not run beside a server (restore, store copy, migrate up) call it; they then open the store with ServerLock false.

func Name

func Name(driver string) string

Name is the driver's name as the health checker and logs report it.

Types

type Backend

type Backend interface {
	store.Store
	Ping(ctx context.Context) error
}

Backend is a store plus what the server and the CLIs need beyond store.Store.

func Open

func Open(ctx context.Context, o Options) (Backend, error)

Open opens the store o names.

type Checkpointer

type Checkpointer interface {
	StartCheckpointer(ctx context.Context, interval time.Duration, logger *slog.Logger) <-chan struct{}
}

Checkpointer is implemented by a backend with a write-ahead log to fold back (SQLite).

type Options

type Options struct {
	Driver      string // DriverSQLite (also when empty) or DriverPostgres
	SQLitePath  string
	PostgresDSN string
	MaxConns    int // PostgreSQL write pool size
	// AutoMigrate applies pending migrations before Open returns. The zero
	// Options never migrates, unlike sqlite.DefaultOptions and
	// postgres.DefaultOptions. The server sets it; the backup and worker CLIs
	// leave it false because they write into an existing schema and must
	// never create one; migrate drives goose itself.
	AutoMigrate bool
	ServerLock  bool // take the single-server lock (both drivers)
	// HA says the server runs in a high-availability group: on PostgreSQL its
	// lock is shared with the group's other servers and its sessions are
	// bounded by LeaseTTL (see postgres.Options). Ignored by SQLite, which
	// cannot run a group.
	HA       bool
	LeaseTTL time.Duration
	Logger   *slog.Logger
}

Options says which store to open and how.

Jump to

Keyboard shortcuts

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