db

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCompactionBusy = errors.New("database maintenance in progress")

Functions

This section is empty.

Types

type CompactOptions added in v0.34.0

type CompactOptions struct {
	MinReclaimBytes        int64
	MinReclaimPercent      int64
	MinReclaimPercentFloor int64
	// MinInterval also throttles failed attempts.
	MinInterval time.Duration
	// PauseTimeout bounds draining transactions. Zero selects the default.
	PauseTimeout time.Duration
	// CopyTimeout bounds copying independently of the drain. Zero uses the
	// caller's context. Filesystem calls cannot be interrupted.
	CopyTimeout time.Duration
	// Progress receives phase changes without blocking maintenance. A full channel drops updates.
	Progress chan<- string
}

CompactOptions controls when a database is compacted. The percentage floor applies even when the reclaimable byte threshold is met.

func (CompactOptions) MeetsReclaimThreshold added in v0.34.0

func (o CompactOptions) MeetsReclaimThreshold(size, reclaimable int64) bool

MeetsReclaimThreshold reports whether reclaimable space meets the percentage floor and at least one configured byte or percentage threshold.

type CompactResult added in v0.34.0

type CompactResult struct {
	// Compacted remains true if a failure occurs after replacement.
	Compacted  bool
	Reason     string
	SizeBefore int64
	SizeAfter  int64
	// Reclaimable includes both free and pending pages.
	Reclaimable int64
	Duration    time.Duration
}

type CompactionStats added in v0.34.0

type CompactionStats struct {
	Size int64
	// Reclaimable includes pending pages, which become available after readers drain.
	Reclaimable int64
}

func (CompactionStats) RequiredSpace added in v0.34.0

func (s CompactionStats) RequiredSpace() int64

RequiredSpace estimates the replacement file plus room for allocation overhead.

type Compactor added in v0.34.0

type Compactor interface {
	// CompactionStats returns ErrCompactionBusy rather than waiting for maintenance.
	CompactionStats() (CompactionStats, error)
	Compact(ctx context.Context, opt CompactOptions) (CompactResult, error)
}

type DB

type DB interface {
	io.Closer
	Transactor
}

type Transactor

type Transactor interface {
	View(fn func(*bolt.Tx) error) error
	Update(fn func(*bolt.Tx) error) error
}

Transactor is the database interface for running transactions

Directories

Path Synopsis
Package compaction schedules database maintenance independently of the storage engine.
Package compaction schedules database maintenance independently of the storage engine.

Jump to

Keyboard shortcuts

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