Documentation
¶
Index ¶
- Constants
- Variables
- type Branch
- type BranchState
- type Layer
- type MaskScript
- type Registry
- func (r *Registry) BumpSourceGeneration(id, newVolume string) error
- func (r *Registry) Close() error
- func (r *Registry) CommitFreeze(parentID, childID, layerVolume, newParentRW, containerID, host string, ...) (*Layer, error)
- func (r *Registry) CountBranchesReferencingLayer(layerID string) (int, error)
- func (r *Registry) CountLiveBranchesByRWVolume(volume string) (int, error)
- func (r *Registry) CountLiveBranchesBySource(sourceID string) (int, error)
- func (r *Registry) CountLiveBranchesByVolume(volume string) (int, error)
- func (r *Registry) CreateBranch(b *Branch) error
- func (r *Registry) CreateLayer(l *Layer) error
- func (r *Registry) CreateSource(s *Source) error
- func (r *Registry) DeleteLayer(id string) error
- func (r *Registry) DeleteSource(id string) error
- func (r *Registry) GetBranchByName(name string) (*Branch, error)
- func (r *Registry) GetLayer(id string) (*Layer, error)
- func (r *Registry) GetMaskScripts(sourceID string) ([]MaskScript, error)
- func (r *Registry) GetSourceByID(id string) (*Source, error)
- func (r *Registry) GetSourceByName(name string) (*Source, error)
- func (r *Registry) LayerChain(branchID string) ([]Layer, error)
- func (r *Registry) ListExpiredBranches(now string) ([]*Branch, error)
- func (r *Registry) ListLayersBySource(sourceID string) ([]*Layer, error)
- func (r *Registry) ListLiveBranches() ([]*Branch, error)
- func (r *Registry) ListSources() ([]*Source, error)
- func (r *Registry) MarkBranchReady(id, containerID, host string, port int) error
- func (r *Registry) SetMaskScripts(sourceID string, scripts []MaskScript) error
- func (r *Registry) SetSourceState(id string, to SourceState, reason string) error
- func (r *Registry) TransitionBranch(id string, to BranchState, reason string) error
- type Source
- type SourceState
Constants ¶
const ( SourceSeeding SourceState = "seeding" SourceReady SourceState = "ready" SourceFailed SourceState = "failed" BranchCreating BranchState = "creating" BranchReady BranchState = "ready" BranchFailed BranchState = "failed" BranchResetting BranchState = "resetting" BranchDestroying BranchState = "destroying" BranchDestroyed BranchState = "destroyed" )
Variables ¶
var ErrNotFound = errors.New("not found")
var ErrUnsupportedPGVersion = errors.New("unsupported pg_version")
ErrUnsupportedPGVersion rejects sources whose pg_version is outside the supported matrix. Majors 14-18 only: branch startup relies on recovery_init_sync_method=syncfs, which PG 13 and older do not have.
Functions ¶
This section is empty.
Types ¶
type Branch ¶
type Branch struct {
ID, Name, SourceID, ContainerID, RWVolume string
SourceVolume string // source volume the branch was created from
ExpiresAt string // RFC3339, "" = never
Host string // address the instance listens on (127.0.0.1 for docker, pod IP for k8s)
BaseLayerID string // top of the layer chain the branch bases on; "" = the source volume directly
ParentBranchName string // display-only: branch this one was created from ("" = created from the source)
Port int
State BranchState
CreatedAt string
}
type BranchState ¶
type BranchState string
type Layer ¶
type Layer struct {
ID, SourceID, Volume, ParentLayerID string
}
Layer is a frozen branch rw volume: an immutable overlay layer between the source volume and the branches cloned from that branch. Layers chain via ParentLayerID ("" = the layer sits directly on the source volume).
type MaskScript ¶
MaskScript is one masking statement: SQL the engine runs (via in-container psql) on every new/reset branch of the owning source, in stored order.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) BumpSourceGeneration ¶
BumpSourceGeneration advances a source to its next generation volume after a successful refresh seed.
func (*Registry) CommitFreeze ¶
func (r *Registry) CommitFreeze(parentID, childID, layerVolume, newParentRW, containerID, host string, port int, reason string) (*Layer, error)
CommitFreeze atomically records a completed freeze, once the parent is running on its fresh rw volume and the child instance is up:
- the parent's old rw volume becomes a new immutable layer (chained onto the parent's previous base layer, if any),
- the parent row swaps to the fresh rw volume + new container/host/port and transitions resetting -> ready,
- the child branch bases on the new layer.
The parent must be mid-freeze (resetting); all of it commits or none does.
func (*Registry) CountBranchesReferencingLayer ¶
CountBranchesReferencingLayer computes a layer's refcount: the number of live branches whose layer chain contains it (directly or via descendants). Refcounts are derived, never stored.
func (*Registry) CountLiveBranchesByRWVolume ¶
CountLiveBranchesByRWVolume counts live branches whose writable layer is the given volume/dataset. Used as a GC guard: a volume that is some live branch's rw layer must never be removed as an orphaned source layer (zfs children record their parent's clone dataset as their SourceVolume).
func (*Registry) CountLiveBranchesBySource ¶
func (*Registry) CountLiveBranchesByVolume ¶
func (*Registry) CreateBranch ¶
func (*Registry) CreateLayer ¶
CreateLayer records a frozen layer (assigns its ID).
func (*Registry) CreateSource ¶
func (*Registry) DeleteLayer ¶
DeleteLayer removes a layer row. Fails (FK) while a child layer still chains onto it — callers GC topmost-first.
func (*Registry) DeleteSource ¶
DeleteSource removes a source row and its (destroyed) branch history rows. Callers must ensure no live branches reference the source first.
func (*Registry) GetMaskScripts ¶
func (r *Registry) GetMaskScripts(sourceID string) ([]MaskScript, error)
GetMaskScripts returns a source's masking scripts in application order.
func (*Registry) LayerChain ¶
LayerChain resolves a branch's layer chain, topmost (newest) layer first. Empty for branches based directly on the source volume. The full overlay stack is: chain[0], chain[1], …, source volume.
func (*Registry) ListExpiredBranches ¶
ListExpiredBranches returns ready/failed branches whose expiry (RFC3339 UTC, lexicographically comparable) has passed. now must be RFC3339 UTC.
func (*Registry) ListLayersBySource ¶
ListLayersBySource returns every layer frozen under the given source.
func (*Registry) ListLiveBranches ¶
func (*Registry) ListSources ¶
func (*Registry) MarkBranchReady ¶
func (*Registry) SetMaskScripts ¶
func (r *Registry) SetMaskScripts(sourceID string, scripts []MaskScript) error
SetMaskScripts replaces a source's masking scripts with the given ordered list (empty/nil clears them).
func (*Registry) SetSourceState ¶
func (r *Registry) SetSourceState(id string, to SourceState, reason string) error
func (*Registry) TransitionBranch ¶
func (r *Registry) TransitionBranch(id string, to BranchState, reason string) error
type SourceState ¶
type SourceState string