snapshot

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ManifestName = "manifest.json"

Variables

View Source
var ErrNoManifest = errors.New("pack manifest not found")

Functions

func WriteManifest

func WriteManifest(rootDir string, manifest Manifest) error

Types

type DeleteFunc

type DeleteFunc func(ctx context.Context, tx *sql.Tx, table string) error

type ExportOptions

type ExportOptions struct {
	DB            *sql.DB
	RootDir       string
	Tables        []string
	MaxShardBytes int64
	Filter        RowFilter
	Sidecars      []Sidecar
	Now           func() time.Time
}

type FileManifest

type FileManifest struct {
	Path   string `json:"path"`
	Rows   int    `json:"rows"`
	Size   int64  `json:"size,omitempty"`
	SHA256 string `json:"sha256,omitempty"`
}

type ImportOptions

type ImportOptions struct {
	DB           *sql.DB
	RootDir      string
	DeleteTables []string
	DeleteTable  DeleteFunc
	Filter       RowFilter
	ImportRow    RowImportFunc
	Progress     func(ImportProgress)
	BeforeImport func(context.Context, *sql.Tx) error
	AfterImport  func(context.Context, *sql.Tx) error
}

type ImportPlan

type ImportPlan struct {
	Full   bool
	Reason string
	Tables []TableImportPlan
}

func PlanIncrementalImport

func PlanIncrementalImport(previous, current Manifest) ImportPlan

func (ImportPlan) Changed

func (p ImportPlan) Changed() bool

type ImportProgress

type ImportProgress struct {
	Phase     string
	Table     string
	File      string
	FileIndex int
	FileCount int
	Rows      int
	TotalRows int
}

type IncrementalImportOptions

type IncrementalImportOptions struct {
	DB           *sql.DB
	RootDir      string
	Previous     Manifest
	Current      Manifest
	Plan         ImportPlan
	DeleteTable  DeleteFunc
	Filter       RowFilter
	ImportRow    RowImportFunc
	Progress     func(ImportProgress)
	BeforeImport func(context.Context, *sql.Tx) error
	AfterImport  func(context.Context, *sql.Tx) error
}

type Manifest

type Manifest struct {
	Version     int               `json:"version"`
	GeneratedAt time.Time         `json:"generated_at"`
	Tables      []TableManifest   `json:"tables"`
	Sidecars    []Sidecar         `json:"sidecars,omitempty"`
	Files       map[string]string `json:"files,omitempty"`
}

func Export

func Export(ctx context.Context, opts ExportOptions) (Manifest, error)

func Import

func Import(ctx context.Context, opts ImportOptions) (Manifest, error)

func ReadManifest

func ReadManifest(rootDir string) (Manifest, error)

type RowFilter

type RowFilter func(table string, row map[string]any) (bool, error)

type RowImportFunc

type RowImportFunc func(ctx context.Context, tx *sql.Tx, table string, row map[string]any) error

type Sidecar

type Sidecar struct {
	Name string `json:"name"`
	Path string `json:"path"`
	Kind string `json:"kind,omitempty"`
}

type TableImportMode

type TableImportMode string
const (
	TableImportSkip    TableImportMode = "skip"
	TableImportReplace TableImportMode = "replace"
	TableImportFiles   TableImportMode = "files"
)

type TableImportPlan

type TableImportPlan struct {
	Table  TableManifest
	Mode   TableImportMode
	Files  []FileManifest
	Reason string
}

type TableManifest

type TableManifest struct {
	Name          string         `json:"name"`
	File          string         `json:"file,omitempty"`
	Files         []string       `json:"files"`
	FileManifests []FileManifest `json:"file_manifests,omitempty"`
	Columns       []string       `json:"columns"`
	Rows          int            `json:"rows"`
}

Jump to

Keyboard shortcuts

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