branching

package
v0.102.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package branching defines optional database checkpoint and branching capabilities.

The contracts deliberately live beside dal rather than inside dal.DB. A provider can opt in without widening the mandatory data-access interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedCapability identifies a database configuration a provider
	// cannot safely checkpoint or branch.
	ErrUnsupportedCapability = errors.New("dalgo branching: unsupported capability")

	// ErrNilSourceDB identifies a nil source database.
	ErrNilSourceDB = errors.New("dalgo branching: source database is nil")
	// ErrNilBranchDB identifies a nil branch database.
	ErrNilBranchDB = errors.New("dalgo branching: branch database is nil")
	// ErrReleased identifies a checkpoint that has been released.
	ErrReleased = errors.New("dalgo branching: checkpoint is released")
	// ErrEmptyGeneration identifies an empty checkpoint generation.
	ErrEmptyGeneration = errors.New("dalgo branching: checkpoint generation is empty")
)

Functions

This section is empty.

Types

type Branch

type Branch interface {
	// DB returns the branch's database handle.
	DB() dal.DB
	// Close closes the branch. Close must be idempotent.
	Close(context.Context) error
}

Branch owns a fresh database handle. Close must be idempotent.

type Capability

type Capability struct {
	Provider string
	Version  string
	Mode     string
}

Capability is stable provider metadata recorded in a state-holder manifest.

type Checkpoint

type Checkpoint interface {
	// Generation returns the checkpoint generation.
	Generation() string
	// Branch returns a fresh branch created from this checkpoint.
	Branch(context.Context) (Branch, error)
	// Release releases this checkpoint. Release must be idempotent.
	Release(context.Context) error
}

Checkpoint is immutable provider state from which fresh branches are created. Release must be idempotent.

type Provider

type Provider interface {
	// Capability returns this provider's stable metadata.
	Capability() Capability
	// Capture captures immutable state from the source database.
	Capture(context.Context, dal.DB) (Checkpoint, error)
}

Provider captures immutable state from one source database.

type UnsupportedError

type UnsupportedError struct {
	Provider string
	Mode     string
	Reason   string
}

UnsupportedError names the provider mode rejected by an optional capability.

func (*UnsupportedError) Error

func (e *UnsupportedError) Error() string

func (*UnsupportedError) Unwrap

func (e *UnsupportedError) Unwrap() error

Unwrap supports errors.Is(err, ErrUnsupportedCapability).

Jump to

Keyboard shortcuts

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