snapshot

package
v0.0.0-...-141c82c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSnapshotExists = errors.New("Snapshot exists")
	ErrNoLastSnapshot = errors.New("No last snapshot")
)

Functions

func GetCurrentStateSnapshots

func GetCurrentStateSnapshots(dir string) (string, map[int64]CurrentState, error)

func GetHistoryMd5Hash

func GetHistoryMd5Hash(snapshot MetaData) (string, error)

func GetSnapshotMd5Hash

func GetSnapshotMd5Hash(currentStateSnapshotFile string, historySnapshotFile string) (string, error)

func InProgressFileName

func InProgressFileName(chainID string, height int64) string

Types

type Config

type Config struct {
	WaitForCreationLockTimeout encoding.Duration `` /* 140-byte string literal not displayed */
}

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type Conn

type Conn interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

type CurrentState

type CurrentState struct {
	ChainID string
	Height  int64
}

func NewCurrentSnapshot

func NewCurrentSnapshot(chainID string, height int64) CurrentState

func (CurrentState) CompressedFileName

func (s CurrentState) CompressedFileName() string

func (CurrentState) GetCopySQL

func (s CurrentState) GetCopySQL(dbMetaData DatabaseMetadata, databaseSnapshotsPath string) []string

func (CurrentState) String

func (s CurrentState) String() string

func (CurrentState) UncompressedDataDir

func (s CurrentState) UncompressedDataDir() string

type DatabaseMetadata

type DatabaseMetadata struct {
	TableNameToMetaData map[string]TableMetadata
	DatabaseVersion     int64
}

func NewDatabaseMetaData

func NewDatabaseMetaData(ctx context.Context, connPool *pgxpool.Pool) (DatabaseMetadata, error)

func (DatabaseMetadata) GetHistoryTableNames

func (d DatabaseMetadata) GetHistoryTableNames() []string

type History

type History struct {
	ChainID    string
	HeightFrom int64
	HeightTo   int64
}

func GetHistorySnapshots

func GetHistorySnapshots(snapshotsDir string) (string, []History, error)

func NewHistorySnapshot

func NewHistorySnapshot(chainID string, heightFrom int64, heightTo int64) History

func (History) CompressedFileName

func (h History) CompressedFileName() string

func (History) GetCopySQL

func (h History) GetCopySQL(dbMetaData DatabaseMetadata, databaseSnapshotsPath string) []string

func (History) String

func (h History) String() string

func (History) UncompressedDataDir

func (h History) UncompressedDataDir() string

type HypertablePartitionColumns

type HypertablePartitionColumns struct {
	HypertableName string
	ColumnName     string
}

type IndexInfo

type IndexInfo struct {
	Tablename string
	Indexname string
	Indexdef  string
}

type LoadLog

type LoadLog interface {
	Infof(s string, args ...interface{})
	Info(msg string, fields ...zap.Field)
}

type LoadResult

type LoadResult struct {
	LoadedFromHeight int64
	LoadedToHeight   int64
	RowsLoaded       int64
}

type MetaData

type MetaData struct {
	CurrentStateSnapshot     CurrentState
	HistorySnapshot          History
	CurrentStateSnapshotPath string
	HistorySnapshotPath      string
	DatabaseVersion          int64
}

type Service

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

func NewSnapshotService

func NewSnapshotService(log *logging.Logger, config Config, connPool *pgxpool.Pool,
	snapshotsCopyFromPath string,
	snapshotsCopyToPath string,
	migrateDatabaseToVersion func(version int64) error,
) (*Service, error)

func (*Service) CreateSnapshot

func (b *Service) CreateSnapshot(ctx context.Context, chainID string, toHeight int64) (MetaData, error)

func (*Service) CreateSnapshotAsynchronously

func (b *Service) CreateSnapshotAsynchronously(ctx context.Context, chainID string, toHeight int64) (MetaData, error)

func (*Service) LoadSnapshotData

func (b *Service) LoadSnapshotData(ctx context.Context, log LoadLog, currentStateSnapshot CurrentState,
	contiguousHistory []History, sourceDir string, connConfig sqlstore.ConnectionConfig, withIndexesAndOrderTriggers, verbose bool,
) (LoadResult, error)

func (*Service) SnapshotData

func (b *Service) SnapshotData(ctx context.Context, chainID string, toHeight int64) error

type Span

type Span struct {
	FromHeight int64
	ToHeight   int64
}

type TableMetadata

type TableMetadata struct {
	Name            string
	SortOrder       string
	Hypertable      bool
	PartitionColumn string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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