migrations

package
v0.2010.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package migrations implements upgrade migration handlers.

Index

Constants

View Source
const (
	// DummyUpgradeName is the name of the dummy upgrade, for use in the upgrade descriptor.
	DummyUpgradeName = "__e2e-test-valid"
)
View Source
const (
	// ModuleName is the migration module name.
	ModuleName = "upgrade-migrations"
)

Variables

View Source
var (
	TestEntity entity.Entity
)

Functions

func Register

func Register(name string, handler Handler)

Register registers a new migration handler, by upgrade name.

Types

type Context

type Context struct {
	// Upgrade is the currently pending upgrade structure.
	Upgrade *upgradeApi.PendingUpgrade

	// DataDir is the node's data directory.
	DataDir string

	Logger *logging.Logger
}

Context defines the common context used by migration handlers.

func NewContext

func NewContext(upgrade *upgradeApi.PendingUpgrade, dataDir string) *Context

NewContext returns a new upgrade migration context.

type Handler

type Handler interface {
	// StartupUpgrade is called by the upgrade manager to perform
	// the node startup portion of the upgrade.
	StartupUpgrade(*Context) error

	// ConsensusUpgrade is called by the upgrade manager to perform
	// the consensus portion of the upgrade. The interface argument is
	// a private structure passed to Backend.ConsensusUpgrade by the
	// consensus backend.
	ConsensusUpgrade(*Context, interface{}) error
}

Handler is the interface used by migration handlers.

func GetHandler

func GetHandler(ctx *Context) Handler

GetHandler returns the handler associated with the upgrade described in the context. If the handler does not exist, this is considered a severe programmer error and will result in a panic.

Jump to

Keyboard shortcuts

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