Documentation
¶
Overview ¶
Package compaction schedules database maintenance independently of the storage engine. Database growth is sampled at most every five minutes after committed writes, and reclaimability is checked after enough writes even without growth. Pending compaction waits for an idle period. Arriving writers cancel attempts up to the retry limit; subsequent attempts make writers wait. Changed policy state is checkpointed every five minutes and at close.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("database maintenance already requested or in progress")
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
CompactionStats() (db.CompactionStats, error)
Compact(context.Context, db.CompactOptions) (db.CompactResult, error)
Save(State) error
}
type Config ¶
type Config struct {
ManualOnly bool
WritesPerCheck uint64
SizeWatermark int64
SizeGrowthPercent int64
MinReclaimBytes int64
IdleTimeout time.Duration
MaxRetry int
MinReclaimPercent int64
MinReclaimPercentFloor int64
Metrics *Metrics `json:"-"`
}
func DefaultConfig ¶
func DefaultConfig() Config
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics shares instruments across databases using the daemon's meter provider.
func NewMetrics ¶
func NewMetrics(mp metric.MeterProvider, stateDir string) (*Metrics, error)
type Outcome ¶
type Outcome struct {
Result db.CompactResult
Error string
}
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewFile ¶
NewFile starts a policy with checkpoints beside the database. Its lifetime is controlled by Stop and Close, rather than by a build request's context.
func (*Scheduler) End ¶
End counts only committed writes. It must also run after callback errors or panics.
func (*Scheduler) Inspect ¶
Inspect observes policy state without advancing watermarks or requesting maintenance.