walship

package
v0.8.3 Latest Latest
Warning

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

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

Documentation

Overview

Package walship is an opt-in prototype of continuous SQLite replication by WAL frame shipping (ADR 039). It is not wired into the control plane.

Index

Constants

View Source
const DefaultCheckpointBytes = 16 << 20

DefaultCheckpointBytes is the WAL size at which the shipper checkpoints and lets SQLite restart the WAL.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirSink

type DirSink struct{ Dir string }

DirSink stores replica objects as files under Dir.

func (DirSink) Get

func (d DirSink) Get(name string) (io.ReadCloser, error)

Get opens name.

func (DirSink) List

func (d DirSink) List(prefix string) ([]string, error)

List returns object names with the prefix, sorted.

func (DirSink) Put

func (d DirSink) Put(name string, r io.Reader) error

Put writes name atomically.

type RestoreResult

type RestoreResult struct {
	Generation int
	Epochs     int
	FrameBytes int64
	// Truncated is true when a missing segment stopped replay early.
	Truncated bool
}

RestoreResult describes what Restore replayed.

func Restore

func Restore(ctx context.Context, sink Sink, dest string) (RestoreResult, error)

Restore rebuilds the database at dest from the newest generation in sink.

type Shipper

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

Shipper copies new WAL frames of one SQLite database to a Sink. It holds a read transaction between syncs so SQLite cannot restart the WAL under it.

func New

func New(path string, sink Sink, checkpointBytes int64) (*Shipper, error)

New opens a shipper for the database at path. checkpointBytes <= 0 uses DefaultCheckpointBytes.

func (*Shipper) Close

func (s *Shipper) Close() error

Close releases the read hold and the connection pool.

func (*Shipper) Run

func (s *Shipper) Run(ctx context.Context, interval time.Duration) error

Run syncs every interval until ctx ends.

func (*Shipper) Stats

func (s *Shipper) Stats() Stats

Stats returns a copy of the counters.

func (*Shipper) Sync

func (s *Shipper) Sync(ctx context.Context) error

Sync ships every committed frame not yet shipped, then checkpoints when the WAL is large.

type Sink

type Sink interface {
	Put(name string, r io.Reader) error
	Get(name string) (io.ReadCloser, error)
	List(prefix string) ([]string, error)
}

Sink is where the replica lives (a directory here; an object store later).

type Stats

type Stats struct {
	Generations   int
	Segments      int
	SnapshotBytes int64
	SegmentBytes  int64
	FrameBytes    int64
	Checkpoints   int
}

Stats counts what a Shipper has done since it was created.

Jump to

Keyboard shortcuts

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