checkpoint

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleSQLite    = "sqlite"
	RoleGraphData = "graph-data"
)

Variables

View Source
var (
	ErrPublisherBusy   = errors.New("checkpoint publisher is active")
	ErrPublisherFenced = errors.New("checkpoint publisher was fenced")
)
View Source
var ErrStaleCheckpoint = errors.New("stale checkpoint candidate")

Functions

func CopyRoot added in v0.13.0

func CopyRoot(ctx context.Context, bucket objstore.Bucket, sourcePrefix, targetPrefix string, root *Checkpoint) error

CopyRoot copies one verified immutable root and its blocks between namespaces. It does not copy CURRENT, claims, pins, or maintenance metadata.

Types

type AutoCheckpointer

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

AutoCheckpointer automatically creates checkpoints.

func NewAutoCheckpointer

func NewAutoCheckpointer(manager *Manager, material *materializer.Materializer, interval int64, duration time.Duration) *AutoCheckpointer

NewAutoCheckpointer creates a new auto checkpointer.

func (*AutoCheckpointer) CheckpointOnShutdown

func (a *AutoCheckpointer) CheckpointOnShutdown(ctx context.Context, tip uint64) error

CheckpointOnShutdown creates a checkpoint during shutdown.

func (*AutoCheckpointer) ConfigurePublication

func (a *AutoCheckpointer) ConfigurePublication(eligible func() bool, publish func(context.Context, *Checkpoint) error)

func (*AutoCheckpointer) ConfigurePublisher

func (a *AutoCheckpointer) ConfigurePublisher(owner string, floor func() uint64, advance func(context.Context, uint64) error)

func (*AutoCheckpointer) ConfigureTail

func (a *AutoCheckpointer) ConfigureTail(bytes func() int64, budget int64)

func (*AutoCheckpointer) Start

func (a *AutoCheckpointer) Start(ctx context.Context, tipFunc func() uint64, before func(context.Context) error)

Start starts the automatic checkpoint loop.

func (*AutoCheckpointer) Stop

func (a *AutoCheckpointer) Stop()

Stop stops the automatic checkpoint loop.

type Block

type Block struct {
	Hash       string `json:"hash"`
	Generation uint64 `json:"generation,omitempty"`
	Size       int64  `json:"size"`
}

type Checkpoint

type Checkpoint struct {
	ConfigID   uint     `json:"config_id"`
	Generation uint64   `json:"generation"`
	Index      uint64   `json:"index"`
	Hash       [32]byte `json:"hash"`
	Size       int64    `json:"size"`
	Files      []File   `json:"files"`
	RootHash   [32]byte `json:"-"`
	// contains filtered or unexported fields
}

type File

type File struct {
	Role   string  `json:"role"`
	Hash   string  `json:"hash"`
	Size   int64   `json:"size"`
	Blocks []Block `json:"blocks"`
	Path   string  `json:"-"`
}

type Manager

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

func NewManager

func NewManager(bucket objstore.Bucket, prefix, localDir string, configID ...uint) *Manager

func NewManagerFromEnv

func NewManagerFromEnv(bucket objstore.Bucket, localDir string) *Manager

NewManagerFromEnv creates a checkpoint manager from environment.

func (*Manager) AcquireGenerationClaim added in v0.14.0

func (m *Manager) AcquireGenerationClaim(ctx context.Context, owner string, index uint64, lease time.Duration) (*PublisherClaim, error)

AcquireGenerationClaim reserves one externally fenced recovery index. Unlike consensus publishers it never advances that index on a retry. A generation claim may only succeed in an empty checkpoint namespace or after an earlier claim for the same operation has expired.

func (*Manager) AcquirePublisherClaim

func (m *Manager) AcquirePublisherClaim(ctx context.Context, owner string, minExclusive uint64, lease time.Duration) (*PublisherClaim, error)

func (*Manager) BindPublisherClaim

func (m *Manager) BindPublisherClaim(ctx context.Context, claim *PublisherClaim, index uint64, root [32]byte, lease time.Duration) (*PublisherClaim, error)

func (*Manager) Cleanup

func (m *Manager) Cleanup(ctx context.Context, keep int) error

func (*Manager) CreateFiles

func (m *Manager) CreateFiles(ctx context.Context, claim *PublisherClaim, sources []Source, index uint64) (*Checkpoint, error)

func (*Manager) DownloadAndVerifyRootFiles

func (m *Manager) DownloadAndVerifyRootFiles(ctx context.Context, root *Checkpoint, dir string) ([]File, error)

DownloadAndVerifyRootFiles writes and hashes a root that was already opened. A successful download is immediately reusable by Verify without another object-store read.

func (*Manager) DownloadRootFiles

func (m *Manager) DownloadRootFiles(ctx context.Context, index uint64, rootHash [32]byte, dir string) ([]File, error)

func (*Manager) GarbageCollect

func (m *Manager) GarbageCollect(ctx context.Context, retain map[[32]byte]struct{}, keep int, grace time.Duration) error

func (*Manager) GarbageCollectFrom

func (m *Manager) GarbageCollectFrom(ctx context.Context, retain map[[32]byte]struct{}, keep int, floor uint64, grace time.Duration) error

GarbageCollectFrom retains every root at or above floor. The shared archive recovery base is authoritative for this lower bound.

func (*Manager) Latest

func (m *Manager) Latest() *Checkpoint

func (*Manager) Load

func (m *Manager) Load(ctx context.Context) error

Load performs two exact GETs: CURRENT and its immutable root.

func (*Manager) OpenRoot

func (m *Manager) OpenRoot(ctx context.Context, index uint64, rootHash [32]byte) (*Checkpoint, error)

func (*Manager) PinRecoveryRoot

func (m *Manager) PinRecoveryRoot(ctx context.Context, root *Checkpoint, owner string, lease time.Duration) (*RecoveryPin, error)

PinRecoveryRoot publishes a short-lived, renewable recovery reference under the same maintenance lease used by GC, closing the pin-registration race.

func (*Manager) PromoteCertifiedCurrent

func (m *Manager) PromoteCertifiedCurrent(ctx context.Context, root *Checkpoint) error

PromoteCertifiedCurrent advances CURRENT only after the checkpoint seal is decided. Conditional writes make the pointer monotonic across stale writers.

func (*Manager) ReleasePublisherClaim

func (m *Manager) ReleasePublisherClaim(ctx context.Context, claim *PublisherClaim) error

func (*Manager) RenewPublisherClaim

func (m *Manager) RenewPublisherClaim(ctx context.Context, claim *PublisherClaim, lease time.Duration) (*PublisherClaim, error)

func (*Manager) ValidatePublisherClaim

func (m *Manager) ValidatePublisherClaim(ctx context.Context, owner string, index uint64, root [32]byte) error

func (*Manager) Verify

func (m *Manager) Verify(ctx context.Context, index uint64, rootHash, state [32]byte) error

type PublisherClaim

type PublisherClaim struct {
	ConfigID      uint   `json:"config_id"`
	Generation    uint64 `json:"generation"`
	OwnerID       string `json:"owner_id"`
	Purpose       string `json:"purpose,omitempty"`
	LeaseUntilMS  int64  `json:"lease_until_unix_ms"`
	ReservedIndex uint64 `json:"reserved_index"`
	BoundIndex    uint64 `json:"bound_index,omitempty"`
	RootHash      string `json:"root_hash,omitempty"`
	// contains filtered or unexported fields
}

type RecoveryPin

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

RecoveryPin keeps an immutable checkpoint root and its content-addressed blocks live while a node installs that root.

func (*RecoveryPin) Close

func (p *RecoveryPin) Close(ctx context.Context) error

func (*RecoveryPin) Renew

func (p *RecoveryPin) Renew(ctx context.Context, lease time.Duration) error

func (*RecoveryPin) Root

func (p *RecoveryPin) Root() (*Checkpoint, error)

Root returns the immutable descriptor captured when this recovery pin was committed. It remains usable if a stale GC later removes the canonical root object after the recovery has selected it.

type Source

type Source struct{ Role, Path string }

Jump to

Keyboard shortcuts

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