pm

package
v0.0.0-...-3b037d6 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package pm is a generated GoMock package.

Package pm is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProcessCanceled  = errors.New("pm: process canceledLog")
	ErrBadProcKind      = errors.New("pm: bad process kind")
	ErrNoCommandInGroup = errors.New("pm: no commands in group")
	ErrNoProcess        = errors.New("pm: process not found")
)

Functions

func Encode

func Encode(p *Process) ([]byte, error)

Types

type DefaultLogger

type DefaultLogger struct{}

func (DefaultLogger) Append

func (DefaultLogger) Append(ctx context.Context, event Event)

type ErrorFunc

type ErrorFunc func(error, *Process)

type Event

type Event struct {
	Message    string                 `json:"message"`
	Kind       string                 `json:"kind"`
	PID        string                 `json:"pid"`
	Status     int                    `json:"status"`
	IsRollback bool                   `json:"isRollback"`
	Cursor     int                    `json:"cursor"`
	Command    string                 `json:"command"`
	Stream     string                 `json:"stream"`
	Step       int                    `json:"step"`
	Time       time.Time              `json:"time"`
	UpdatedAt  time.Time              `json:"updatedAt"`
	StatusName string                 `json:"statusName"`
	Context    map[string]interface{} `json:"context"`
	Error      string                 `json:"error"`
}

type FactoryFunc

type FactoryFunc func(*Process) *es.Command

type Groups

type Groups []*Tx

func Group

func Group() Groups

func (*Groups) Step

func (d *Groups) Step(stream string) *Tx

type Handler

type Handler func(*Process) (*es.Command, error)

type HookFunc

type HookFunc func(*Process)

type Logger

type Logger interface {
	Append(ctx context.Context, event Event)
}

type Manager

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

func New

func New(kind string, g Groups, s Store, l Logger, cb es.CommandSendReplier) (*Manager, error)

func (*Manager) CancelProcess

func (m *Manager) CancelProcess(ctx context.Context, pid uuid.UUID) error

func (*Manager) CreateProcess

func (m *Manager) CreateProcess(ctx context.Context, pid uuid.UUID, pc ProcessContext) error

func (*Manager) ErrorHandler

func (m *Manager) ErrorHandler(handler ...ErrorFunc)

func (*Manager) OnCancel

func (m *Manager) OnCancel(hook ...HookFunc)

func (*Manager) OnFailure

func (m *Manager) OnFailure(hook ...HookFunc)

func (*Manager) OnSuccess

func (m *Manager) OnSuccess(hook ...HookFunc)

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

func (*Manager) StartProcess

func (m *Manager) StartProcess(ctx context.Context, pid uuid.UUID) error

func (*Manager) Step

func (m *Manager) Step(name string, fn FactoryFunc)

func (*Manager) SwitchProc

func (m *Manager) SwitchProc(fn ...SwitchProcFunc)

type MockLogger

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

MockLogger is a mock of Logger interface

func NewMockLogger

func NewMockLogger(ctrl *gomock.Controller) *MockLogger

NewMockLogger creates a new mock instance

func (*MockLogger) Append

func (m *MockLogger) Append(ctx context.Context, event Event)

Append mocks base method

func (*MockLogger) EXPECT

func (m *MockLogger) EXPECT() *MockLoggerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

type MockLoggerMockRecorder

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

MockLoggerMockRecorder is the mock recorder for MockLogger

func (*MockLoggerMockRecorder) Append

func (mr *MockLoggerMockRecorder) Append(ctx, event interface{}) *gomock.Call

Append indicates an expected call of Append

type MockStore

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

MockStore is a mock of Store interface

func NewMockStore

func NewMockStore(ctrl *gomock.Controller) *MockStore

NewMockStore creates a new mock instance

func (*MockStore) Append

func (m *MockStore) Append(ctx context.Context, p *Process) error

Append mocks base method

func (*MockStore) EXPECT

func (m *MockStore) EXPECT() *MockStoreMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockStore) Load

func (m *MockStore) Load(ctx context.Context, kind string, pid uuid.UUID) (*Process, error)

Load mocks base method

func (*MockStore) Remove

func (m *MockStore) Remove(ctx context.Context, pid uuid.UUID) error

Remove mocks base method

func (*MockStore) Save

func (m *MockStore) Save(ctx context.Context, p *Process) error

Save mocks base method

type MockStoreMockRecorder

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

MockStoreMockRecorder is the mock recorder for MockStore

func (*MockStoreMockRecorder) Append

func (mr *MockStoreMockRecorder) Append(ctx, p interface{}) *gomock.Call

Append indicates an expected call of Append

func (*MockStoreMockRecorder) Load

func (mr *MockStoreMockRecorder) Load(ctx, kind, pid interface{}) *gomock.Call

Load indicates an expected call of Load

func (*MockStoreMockRecorder) Remove

func (mr *MockStoreMockRecorder) Remove(ctx, pid interface{}) *gomock.Call

Remove indicates an expected call of Remove

func (*MockStoreMockRecorder) Save

func (mr *MockStoreMockRecorder) Save(ctx, p interface{}) *gomock.Call

Save indicates an expected call of Save

type ProcStatus

type ProcStatus int
const (
	Init       ProcStatus = 0
	Processing ProcStatus = 1
	Processed  ProcStatus = 2
	Failed     ProcStatus = 3
	Canceled   ProcStatus = 4
	Unknown    ProcStatus = 5
)

type Process

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

func Decode

func Decode(data []byte) (*Process, error)

func NewProcess

func NewProcess(kind string, pid uuid.UUID, pc ProcessContext) *Process

func (*Process) CommandType

func (p *Process) CommandType() string

func (*Process) Cursor

func (p *Process) Cursor() int

func (*Process) Err

func (p *Process) Err() error

func (*Process) IsCanceled

func (p *Process) IsCanceled() bool

func (*Process) IsFailed

func (p *Process) IsFailed() bool

func (*Process) IsProcessed

func (p *Process) IsProcessed() bool

func (*Process) IsProcessing

func (p *Process) IsProcessing() bool

func (*Process) IsRollback

func (p *Process) IsRollback() bool

func (*Process) Kind

func (p *Process) Kind() string

func (*Process) Make

func (p *Process) Make(payload interface{}) *es.Command

func (*Process) PID

func (p *Process) PID() uuid.UUID

func (*Process) Snapshot

func (p *Process) Snapshot() Snapshot

func (*Process) State

func (p *Process) State() ProcessContext

func (*Process) Status

func (p *Process) Status() ProcStatus

func (*Process) StatusName

func (p *Process) StatusName() string

func (*Process) Step

func (p *Process) Step() int

func (*Process) StreamType

func (p *Process) StreamType() string

func (*Process) UpdatedAt

func (p *Process) UpdatedAt() time.Time

type ProcessContext

type ProcessContext map[string]interface{}

func State

func State() ProcessContext

func (ProcessContext) Copy

func (c ProcessContext) Copy() (copy ProcessContext, err error)

func (ProcessContext) Get

func (c ProcessContext) Get(key string) interface{}

func (ProcessContext) GetBool

func (c ProcessContext) GetBool(key string) (b bool)

func (ProcessContext) GetFloat

func (c ProcessContext) GetFloat(key string) (f float64)

func (ProcessContext) GetInt

func (c ProcessContext) GetInt(key string) (i int)

func (ProcessContext) GetString

func (c ProcessContext) GetString(key string) (s string)

func (ProcessContext) Set

func (c ProcessContext) Set(key string, value interface{})

type Snapshot

type Snapshot struct {
	Kind       string
	PID        string
	Status     int
	IsRollback bool
	Cursor     int
	Command    string
	Step       int
	Context    map[string]interface{}
	UpdatedAt  time.Time
	Err        string
}

type Step

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

func (Step) Command

func (ns Step) Command() *es.Command

func (Step) From

func (ns Step) From() string

func (Step) HasNext

func (ns Step) HasNext() bool

func (Step) Proc

func (ns Step) Proc() *Process

func (Step) Reply

func (ns Step) Reply() *es.Reply

func (Step) To

func (ns Step) To() string

type Store

type Store interface {
	Append(ctx context.Context, p *Process) error
	Save(ctx context.Context, p *Process) error
	Remove(ctx context.Context, pid uuid.UUID) error
	Load(ctx context.Context, kind string, pid uuid.UUID) (*Process, error)
}

type SwitchProcFunc

type SwitchProcFunc func(step Step)

type Tx

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

func (*Tx) Command

func (t *Tx) Command() string

func (*Tx) Commit

func (t *Tx) Commit(command string) *Tx

func (*Tx) HasRollback

func (t *Tx) HasRollback() bool

func (*Tx) Name

func (t *Tx) Name() string

func (*Tx) Rollback

func (t *Tx) Rollback(command string) *Tx

func (*Tx) RollbackCommand

func (t *Tx) RollbackCommand() string

func (*Tx) Step

func (t *Tx) Step() int

Directories

Path Synopsis
logger
store

Jump to

Keyboard shortcuts

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