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 ¶
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 ¶
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 ¶
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).