migrations

package
v2.8.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMigrationTx added in v2.6.1

func ApplyMigrationTx(ctx context.Context, env Env, state State) error

func ApplyMigrations

func ApplyMigrations(ctx context.Context, db *pachsql.DB, baseEnv Env, state State) (retErr error)

ApplyMigrations does the necessary work to actualize state. It will manipulate the objects available in baseEnv, and use the migrations table in db.

func BlockUntil

func BlockUntil(ctx context.Context, db *pachsql.DB, state State) error

BlockUntil blocks until state is actualized. It makes no attempt to perform migrations, hopefully another process is working on that by calling ApplyMigrations. If the cluster ever enters a state newer than the state passed to BlockUntil, it errors.

func Squash added in v2.8.0

func Squash(s *State)

Types

type ApplyOpt added in v2.8.0

type ApplyOpt func(*State)

type Env

type Env struct {
	// TODO: etcd
	ObjectClient   obj.Client
	Tx             *pachsql.Tx
	EtcdClient     *clientv3.Client
	WithTableLocks bool
}

Env contains all the objects that can be manipulated during a migration. The Tx field will be overwritten with the transaction that the migration should be performed in.

func MakeEnv

func MakeEnv(objC obj.Client, etcdC *clientv3.Client) Env

MakeEnv returns a new Env The only advantage to this contructor is you can be sure all the fields are set. You can also create an Env using a struct literal.

func (Env) LockTables added in v2.6.7

func (env Env) LockTables(ctx context.Context, tables ...string) error

type Func

type Func func(ctx context.Context, env Env) error

Func is the type of functions that perform migrations.

type State

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

State represents a state of the cluster, including all the steps taken to get there.

func CollectStates added in v2.6.1

func CollectStates(s State) []State

CollectStates does a reverse order traversal of a linked list and adds each item to a slice

func InitialState

func InitialState() State

InitialState returns a cluster that has no migrations. The initial state contains a change which is just to create the migration table.

func (State) Apply

func (s State) Apply(name string, fn Func, opts ...ApplyOpt) State

Apply applies a Func to the state and returns a new state.

func (State) Number

func (s State) Number() int

Number returns the number of changes to be applied before the state can be actualized. The number of the initial state is 0 State number n requires n changes from the initial state.

Jump to

Keyboard shortcuts

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