durability

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFlushFunc

func NewFlushFunc(mode FlushMode) (func(ctx context.Context, conn *driver.Conn) error, error)

NewFlushFunc creates a flush function based on the given FlushMode. Returns an error if the mode is invalid.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(opts Options) *Controller

func (*Controller) Flush

func (c *Controller) Flush(ctx context.Context, waitIdleDuration time.Duration, mode FlushMode) error

Flush perform fsync or WAL checkpoint (depends on FlushMode) on sqlite When waitIdleDuration > 0, wait for waitIdleTime since the last write tx got released

func (*Controller) MarkCleanAfterCheck added in v0.4.1

func (c *Controller) MarkCleanAfterCheck()

MarkCleanAfterCheck marks the DB as clean after a successful integrity check. This should be called after quickcheck/integrity verification when no corruption is found.

func (*Controller) OnOpen

func (c *Controller) OnOpen(ctx context.Context) (dirty bool, err error)

func (*Controller) OnWriteEvent

func (c *Controller) OnWriteEvent(event driver.EventType)

func (*Controller) Start

func (c *Controller) Start(ctx context.Context) error

func (*Controller) Stop

func (c *Controller) Stop() error

type FlushMode

type FlushMode string

FlushMode represents how to flush data during idle periods

const (
	FlushModeFsync              FlushMode = "FSYNC"
	FlushModeCheckpointPassive  FlushMode = "CHECKPOINT_PASSIVE"
	FlushModeCheckpointFull     FlushMode = "CHECKPOINT_FULL"
	FlushModeCheckpointRestart  FlushMode = "CHECKPOINT_RESTART"
	FlushModeCheckpointTruncate FlushMode = "CHECKPOINT_TRUNCATE"
)

type Options

type Options struct {
	AutoFlushEnable    bool
	AutoFlushIdleAfter time.Duration
	AutoFlushFunc      func(ctx context.Context, conn *driver.Conn) error

	// AcquireWrite acquires write connection. If silent is true, won't trigger write events on release
	AcquireWrite func(ctx context.Context, fn func(conn *driver.Conn) error) error
	Sentinel     Sentinel
	Logger       *log.Logger
}

type Sentinel

type Sentinel interface {
	OnOpen(ctx context.Context) (dirty bool, err error)
	MarkDirty()
	MarkClean()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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