Documentation
¶
Overview ¶
Package db provides utilities for working with databases.
Index ¶
- Variables
- func Version(ctx *stopper.Context, conn *pgxpool.Conn) (*semver.CockroachVersion, error)
- type Database
- type ExternalConn
- func (c *ExternalConn) BackupInfo(ctx *stopper.Context, conn *pgxpool.Conn, loc string, table KvTable) ([]TableBackup, error)
- func (c *ExternalConn) Drop(ctx *stopper.Context, conn *pgxpool.Conn) error
- func (c *ExternalConn) ListTableBackups(ctx *stopper.Context, conn *pgxpool.Conn) ([]string, error)
- func (c *ExternalConn) Stats(ctx *stopper.Context, conn *pgxpool.Conn) ([]*Stats, error)
- func (c *ExternalConn) String() string
- func (c *ExternalConn) SuggestedParams() blob.Params
- type Ident
- type KvTable
- func (t *KvTable) Backup(ctx *stopper.Context, conn *pgxpool.Conn, dest *ExternalConn, incremental bool) error
- func (t *KvTable) Create(ctx *stopper.Context, conn *pgxpool.Conn) error
- func (t *KvTable) Drop(ctx *stopper.Context, conn *pgxpool.Conn) error
- func (t *KvTable) Fingerprint(ctx *stopper.Context, conn *pgxpool.Conn) (string, error)
- func (t *KvTable) LeaseholderCount(ctx *stopper.Context, conn *pgxpool.Conn) (int, error)
- func (t *KvTable) LocalName() string
- func (t *KvTable) PendingJobs(ctx *stopper.Context, conn *pgxpool.Conn) ([]int64, error)
- func (t *KvTable) PresplitAndScatter(ctx *stopper.Context, conn *pgxpool.Conn, ranges int) error
- func (t *KvTable) Restore(ctx *stopper.Context, conn *pgxpool.Conn, from *ExternalConn, ...) error
- func (t *KvTable) Scatter(ctx *stopper.Context, conn *pgxpool.Conn) error
- func (t *KvTable) SeedRanges(ctx *stopper.Context, conn *pgxpool.Conn, ranges int) error
- func (t *KvTable) Split(ctx *stopper.Context, conn *pgxpool.Conn, points []string) error
- func (t *KvTable) String() string
- func (t *KvTable) Upsert(ctx *stopper.Context, conn *pgxpool.Conn, key, value string) error
- type Schema
- type Stats
- type TableBackup
- type TestEnv
Constants ¶
This section is empty.
Variables ¶
var MinVersionForStats = semver.MustSemver("v25.1.0")
MinVersionForStats is the minimum version required for retrieving statistics.
var Public = Schema{ Name: Ident("public"), }
Public is the public schema.
Functions ¶
Types ¶
type Database ¶
type Database struct {
Name Ident
}
Database represents a database in the system.
type ExternalConn ¶
type ExternalConn struct {
// contains filtered or unexported fields
}
ExternalConn represents an external connection to blob storage.
func NewExternalConn ¶
func NewExternalConn( ctx *stopper.Context, conn *pgxpool.Conn, blob blob.Storage, ) (*ExternalConn, error)
NewExternalConn creates a new external connection.
func (*ExternalConn) BackupInfo ¶
func (c *ExternalConn) BackupInfo( ctx *stopper.Context, conn *pgxpool.Conn, loc string, table KvTable, ) ([]TableBackup, error)
BackupInfo retrieves backup information for a specific table.
func (*ExternalConn) ListTableBackups ¶
func (c *ExternalConn) ListTableBackups( ctx *stopper.Context, conn *pgxpool.Conn, ) ([]string, error)
ListTableBackups lists all table backups in the external connection.
func (*ExternalConn) String ¶
func (c *ExternalConn) String() string
String returns the string representation of the external connection.
func (*ExternalConn) SuggestedParams ¶
func (c *ExternalConn) SuggestedParams() blob.Params
SuggestedParams returns the suggested parameters for the external connection.
type KvTable ¶
KvTable represents a key-value table in the database.
func (*KvTable) Backup ¶
func (t *KvTable) Backup( ctx *stopper.Context, conn *pgxpool.Conn, dest *ExternalConn, incremental bool, ) error
Backup creates a backup of the table.
func (*KvTable) Fingerprint ¶
Fingerprint returns a fingerprint for the table.
func (*KvTable) LeaseholderCount ¶ added in v0.3.0
LeaseholderCount returns the number of distinct nodes currently holding leases for the table's ranges. Used to observe how SCATTER distributed the ranges before a backup.
func (*KvTable) PendingJobs ¶ added in v0.2.1
PendingJobs returns a list of job IDs that are still pending (not succeeded or failed).
func (*KvTable) PresplitAndScatter ¶ added in v0.3.0
PresplitAndScatter presplits the table into `ranges` ranges and scatters them across the cluster so that backup is more likely to exercise every node.
func (*KvTable) Restore ¶
func (t *KvTable) Restore( ctx *stopper.Context, conn *pgxpool.Conn, from *ExternalConn, original *KvTable, ) error
Restore restores the table from a backup.
func (*KvTable) Scatter ¶ added in v0.3.0
Scatter distributes the table's ranges across the cluster nodes.
func (*KvTable) SeedRanges ¶ added in v0.3.0
SeedRanges inserts one deterministic row per range so that scattered ranges have data to export during backup. Call after PresplitAndScatter.
func (*KvTable) Split ¶ added in v0.3.0
Split presplits the table at the given primary-key boundaries.
type Stats ¶
type Stats struct {
Node int
Locality string
ErrStr string
Transferred string
ReadSpeed string
WriteSpeed string
Success bool
CanDelete bool
}
Stats represents statistics about the external connection.
type TableBackup ¶
TableBackup represents a backup of a table.
type TestEnv ¶
TestEnv encapsulates the resources needed for testing.
func NewTestEnv ¶
NewTestEnv creates a new test environment.