backup

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	Index    int    `json:"index"`
	File     string `json:"file"`
	RowCount int64  `json:"row_count"`
	SHA256   string `json:"sha256"`
}

Chunk represents a single data file in the backup.

type Compressor

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

Compressor provides a zstd compressed writer.

func NewCompressor

func NewCompressor(w io.Writer) (*Compressor, error)

NewCompressor creates a new Compressor wrapping the provided writer.

func (*Compressor) Close

func (c *Compressor) Close() error

Close finalizes the compression and closes the encoder.

func (*Compressor) Flush

func (c *Compressor) Flush() error

Flush flushes the encoder's buffers.

func (*Compressor) Write

func (c *Compressor) Write(p []byte) (n int, err error)

Write writes compressed data to the underlying writer.

type Engine

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

Engine handles the backup workflow.

func NewEngine

func NewEngine(s storage.Storage, ser Serializer) *Engine

NewEngine creates a new backup engine.

func (*Engine) Backup

func (e *Engine) Backup(ctx context.Context, opID string, src adapter.SourceAdapter, table string, chunkSize int64) (*Manifest, error)

Backup runs the backup process for a given source and table.

type Manifest

type Manifest struct {
	Version        int            `json:"version"`
	OperationID    string         `json:"operation_id"`
	Source         SourceMetadata `json:"source"`
	CreatedAt      time.Time      `json:"created_at"`
	RowCount       int64          `json:"row_count"`
	ChunkSizeBytes int64          `json:"chunk_size_bytes"`
	Chunks         []Chunk        `json:"chunks"`
	SchemaSnapshot schema.Schema  `json:"schema_snapshot"`
}

Manifest represents the index of a completed backup.

type NDJSONSerializer

type NDJSONSerializer struct{}

NDJSONSerializer implements the Serializer interface for Newline Delimited JSON.

func NewNDJSONSerializer

func NewNDJSONSerializer() *NDJSONSerializer

NewNDJSONSerializer creates a new NDJSONSerializer.

func (*NDJSONSerializer) Close

func (s *NDJSONSerializer) Close(w io.Writer) error

func (*NDJSONSerializer) Flush

func (s *NDJSONSerializer) Flush(w io.Writer) error

func (*NDJSONSerializer) Serialize

func (s *NDJSONSerializer) Serialize(w io.Writer, rec *record.Record) error

type ParquetSerializer

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

ParquetSerializer implements the Serializer interface for Parquet format.

func NewParquetSerializer

func NewParquetSerializer(s *schema.Schema) (*ParquetSerializer, error)

NewParquetSerializer creates a new ParquetSerializer for the given schema.

func (*ParquetSerializer) Close

func (s *ParquetSerializer) Close(w io.Writer) error

func (*ParquetSerializer) Flush

func (s *ParquetSerializer) Flush(w io.Writer) error

func (*ParquetSerializer) Serialize

func (s *ParquetSerializer) Serialize(w io.Writer, rec *record.Record) error

type RestoreEngine

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

RestoreEngine handles the restoration workflow.

func NewRestoreEngine

func NewRestoreEngine(s storage.Storage, target adapter.TargetAdapter) *RestoreEngine

NewRestoreEngine creates a new restore engine.

func (*RestoreEngine) Restore

func (e *RestoreEngine) Restore(ctx context.Context, manifestPath string) error

Restore restores a backup from storage to the target database.

type Serializer

type Serializer interface {
	// Serialize writes a single record to the writer.
	Serialize(w io.Writer, rec *record.Record) error

	// Flush ensures any buffered data is written to the writer.
	Flush(w io.Writer) error

	// Close finalizes the serialization process.
	Close(w io.Writer) error
}

Serializer defines the interface for converting records into a streamable format.

type SourceMetadata

type SourceMetadata struct {
	Type  string `json:"type"`
	DB    string `json:"db"`
	Table string `json:"table"`
}

SourceMetadata contains information about the database source.

Jump to

Keyboard shortcuts

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