moverepowf

package
v0.0.0-...-4450389 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package `moverepowf` implements the move-repo workflow, which simultaneously changes the location of a real repo and its shadow repo.

The workflow supports passing the repo to a different Nogfsostad instance.

Workflow Events

The workflow is initiated on a registry with `RegistryEvent_EV_FSO_REPO_MOVE_ACCEPTED`, currently by an admin using `nogfsoctl begin-move-repo`.

The old Nogfsostad, the new Nogfsostad, and Nogappd observe the registry event and start watching the workflow.

Nogfsoregd repoinit determines the file host details and posts `RepoEvent_EV_FSO_REPO_MOVE_STARTED`.

Nogfsoregd replicate initializes the workflow aggregate with `WorkflowEvent_EV_FSO_REPO_MOVE_STARTED`.

Nogappd posts `WorkflowEvent_EV_FSO_REPO_MOVE_APP_ACCEPTED` to confirm that the repo has been disabled and is ready to be moved to the the new repo location. The event should only be used on a system level, for example to confirm that Nogappd has updated the MongoDB state. The event should not be used to implement a GUI workflow that involves user interaction. One assumption is that a workflow makes steady progress if all systems are functioning properly, without being blocked for an unknown period, because it is waiting for a user.

The old Nogfsostad disables the repo and posts `WorkflowEvent_EV_FSO_REPO_MOVE_STA_RELEASED` to confirm that the repo has been released.

The new Nogfsostad determines the new shadow location. It logs a message that asks an admin to move the real repo and the shadow repo. This step should be automated in the future, by calling a sudo-like service to execute a privileged operation. For now, an admin moves the repos, changes ownership if necessary, and confirms with `nogfsoctl commit-move-repo` which yields `WorkflowEvent_EV_FSO_REPO_MOVED`.

Nogfsoregd replicate commits the move with `RepoEvent_EV_FSO_REPO_MOVED` and `RegistryEvent_EV_FSO_REPO_MOVED`. It terminates the workflow with `WorkflowEvent_EV_FSO_REPO_MOVE_COMMITTED`.

Nogappd and the new Nogfsostad both enable the repo at the new location.

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = errors.New("workflow conflict")
View Source
var ErrConflictInit = errors.New("workflow init conflict")
View Source
var ErrConflictStateAdvanced = errors.New("workflow state has advanced")
View Source
var ErrInvalidCommand = errors.New("invalid workflow command")
View Source
var ErrInvalidEventType = errors.New("invalid event type")
View Source
var ErrMoved = errors.New("workflow move completed")
View Source
var ErrNotMoved = errors.New("workflow did not complete move")
View Source
var ErrStaActive = errors.New("nogfsostad has yet not disabled the repo")
View Source
var ErrTerminated = errors.New("workflow terminated")
View Source
var ErrUninitialized = errors.New("workflow uninitialized")
View Source
var NoVC = events.NoVC

`NoVC` is a sentinel value that can be passed in place of `vid` to indicate that concurrency version checks are skipped.

Functions

This section is empty.

Types

type Advancer

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

The bools indicate which part of the state has been duplicated.

func (*Advancer) Advance

func (a *Advancer) Advance(s events.State, ev events.Event) events.State

type Behavior

type Behavior struct{}

func (Behavior) NewAdvancer

func (Behavior) NewAdvancer() events.Advancer

func (Behavior) NewEvent

func (Behavior) NewEvent() events.Event

func (Behavior) NewState

func (Behavior) NewState(id uuid.I) events.State

func (Behavior) Tell

func (Behavior) Tell(
	s events.State, c events.Command,
) ([]events.Event, error)

type CmdCommit

type CmdCommit struct {
	NewShadowPath string
}

func (*CmdCommit) AggregateCommand

func (*CmdCommit) AggregateCommand()

type CmdExit

type CmdExit struct{}

func (*CmdExit) AggregateCommand

func (*CmdExit) AggregateCommand()

type CmdInit

type CmdInit struct {
	RepoId        uuid.I
	RepoEventId   ulid.I
	OldGlobalPath string
	OldFileHost   string
	OldHostPath   string
	OldShadowPath string
	NewGlobalPath string
	NewFileHost   string
	NewHostPath   string
}

func (*CmdInit) AggregateCommand

func (*CmdInit) AggregateCommand()

type CmdPostAppAccepted

type CmdPostAppAccepted struct{}

func (*CmdPostAppAccepted) AggregateCommand

func (*CmdPostAppAccepted) AggregateCommand()

type CmdPostStadReleased

type CmdPostStadReleased struct{}

func (*CmdPostStadReleased) AggregateCommand

func (*CmdPostStadReleased) AggregateCommand()

type Event

type Event struct{ wfev.Event }

func (*Event) UnmarshalProto

func (ev *Event) UnmarshalProto(data []byte) error

type State

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

func (*State) AggregateState

func (*State) AggregateState()

func (*State) Id

func (s *State) Id() uuid.I

func (*State) IsTerminated

func (st *State) IsTerminated() bool

func (*State) RepoId

func (st *State) RepoId() uuid.I

func (*State) SetVid

func (s *State) SetVid(vid ulid.I)

func (*State) Vid

func (s *State) Vid() ulid.I

type Workflows

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

func New

func New(journal *events.Journal) *Workflows

func (*Workflows) Commit

func (r *Workflows) Commit(
	id uuid.I, vid ulid.I, newShadowPath string,
) (ulid.I, error)

`Commit()` completes the move.

func (*Workflows) Exit

func (r *Workflows) Exit(id uuid.I, vid ulid.I) (ulid.I, error)

`Exit()` terminates the workflow.

The workflow can currently only terminate successfully, which may change in the future when we add more error handling.

func (*Workflows) FindId

func (r *Workflows) FindId(id uuid.I) (*State, error)

func (*Workflows) Init

func (r *Workflows) Init(
	id uuid.I, cmd *CmdInit,
) (ulid.I, error)

`Init()` initializes a workflow.

Nogfsoregd replicate calls it on `RepoEvent_EV_FSO_REPO_MOVE_STARTED`.

func (*Workflows) PostAppAccepted

func (r *Workflows) PostAppAccepted(id uuid.I, vid ulid.I) (ulid.I, error)

`PostAppAccepted()` adds an event that indicates that Nogappd has acknowledged the move.

func (*Workflows) PostStadReleased

func (r *Workflows) PostStadReleased(id uuid.I, vid ulid.I) (ulid.I, error)

`PostStadReleased()` adds an event that indicates that Nogfsostad has released the repo.

Jump to

Keyboard shortcuts

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