Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( StatusFailed = Status{"failed"} StatusFinished = Status{"finished"} )
View Source
var ( ErrStateNotFound = errors.New("state not found") ErrStatusNotFound = errors.New("status not found") )
Functions ¶
This section is empty.
Types ¶
type Migration ¶
type Migration struct {
// contains filtered or unexported fields
}
func MustNewMigration ¶
func MustNewMigration(name string, fn MigrationFunc) Migration
func NewMigration ¶
func NewMigration(name string, fn MigrationFunc) (Migration, error)
func (Migration) Fn ¶
func (m Migration) Fn() MigrationFunc
type MigrationFunc ¶
type MigrationFunc func(ctx context.Context, state State, saveStateFunc SaveStateFunc) error
MigrationFunc is executed with the previously saved state. If the migration func is executed for the first time then the saved state will be an empty map. State is saved by calling the provided function. If a migration function returns an error it will be executed again. If a function doesn't return an error it should not be executed again.
type Migrations ¶
type Migrations struct {
// contains filtered or unexported fields
}
func MustNewMigrations ¶
func MustNewMigrations(migrations []Migration) Migrations
func NewMigrations ¶
func NewMigrations(migrations []Migration) (Migrations, error)
func (Migrations) Count ¶
func (m Migrations) Count() int
func (Migrations) List ¶
func (m Migrations) List() []Migration
type ProgressCallback ¶
type ProgressCallback interface { // OnRunning is only called when a migration is actually being executed. OnRunning(migrationIndex int, migrationsCount int) // OnError is called when the migration process for one of the migrations // fails with an error. OnError(migrationIndex int, migrationsCount int, err error) // OnDone is always called once all migrations were successfully executed // even if no migrations were run. OnDone(migrationsCount int) }
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func (Runner) Run ¶
func (r Runner) Run(ctx context.Context, migrations Migrations, callback ProgressCallback) error
type SaveStateFunc ¶
type Storage ¶
type Storage interface { // LoadState returns ErrStateNotFound if state has not been saved yet. LoadState(name string) (State, error) SaveState(name string, state State) error // LoadStatus returns ErrStatusNotFound if status has not been saved yet. LoadStatus(name string) (Status, error) SaveStatus(name string, status Status) error }
Click to show internal directories.
Click to hide internal directories.