migratekvdb

package
v0.1.32-beta Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultChunkSize is 20MB (leaving room for overhead).
	DefaultChunkSize = 20 * 1024 * 1024

	// MaxChunkSize is 500MB to prevent excessive memory usage.
	MaxChunkSize = 500 * 1024 * 1024
)

Size constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketPath

type BucketPath struct {
	// StringPath is the hex-encoded path with / delimiters for logging.
	StringPath string

	// RawPath contains the original bucket names as raw bytes.
	RawPath [][]byte
}

BucketPath represents a path in the database with both string and raw representations.

func NewBucketPath

func NewBucketPath(buckets [][]byte) BucketPath

NewBucketPath creates a bucket path from raw bucket names.

func (BucketPath) AppendBucket

func (bp BucketPath) AppendBucket(bucket []byte) BucketPath

AppendBucket creates a new BucketPath with an additional bucket.

func (BucketPath) Equal

func (bp BucketPath) Equal(other BucketPath) bool

Equal compares two bucket paths for equality.

func (BucketPath) HasPath

func (bp BucketPath) HasPath() bool

HasPath returns true if the BucketPath contains any path elements.

func (BucketPath) MarshalJSON

func (bp BucketPath) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface by marshaling the raw byte arrays directly.

func (BucketPath) String

func (bp BucketPath) String() string

String implements the Stringer interface.

func (*BucketPath) UnmarshalJSON

func (bp *BucketPath) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface by unmarshaling directly into the raw byte arrays.

type Config

type Config struct {
	// ChunkSize is the number of items (key-value pairs or buckets) to
	// process in a single transaction in bytes.
	ChunkSize uint64

	// Logger is the logger to use for logging.
	Logger btclog.Logger

	// MetaDB is the database that stores the migration/verification state.
	// We store it separately to not clutter the source or destination
	// databases.
	MetaDB *bbolt.DB

	// DBPrefixName is the prefix of the database name.
	DBPrefixName string
}

Config holds the configuration for the migrator.

type MigrationState

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

MigrationState holds migration-specific state for resumability of the process.

func (*MigrationState) String

func (s *MigrationState) String() string

String returns a string representation of the persisted state.

type Migrator

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

Migrator handles the chunked migration of bolt databases. It supports:

  • Resumable migrations through state tracking
  • Chunk-based processing to handle large databases
  • Verification of migrated data (also resumable)
  • Progress logging

func New

func New(cfg Config) (*Migrator, error)

New creates a new Migrator with the given configuration.

func (*Migrator) Migrate

func (m *Migrator) Migrate(ctx context.Context, sourceDB,
	targetDB kvdb.Backend) error

Migrate performs the migration of the source database to the target database.

func (*Migrator) VerifyMigration

func (m *Migrator) VerifyMigration(ctx context.Context,
	sourceDB, targetDB kvdb.Backend, force bool) error

VerifyMigration verifies the migration by comparing the source and target databases.

type VerificationState

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

VerificationState holds verification-specific state for resumability of the process.

Jump to

Keyboard shortcuts

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