group

package
v0.0.0-...-da8027b Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package definitions is a generated GoMock package.

Package group is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProcessCanceled  = errors.New("process canceled")
	ErrBadProcKind      = errors.New("unknown process type")
	ErrNoStepsAvailable = errors.New("no steps available")
	ErrNoProcess        = errors.New("process not found")
	ErrTransitionStatus = errors.New("transition status")
)

Functions

func Encode

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

func Run

func Run(ctx context.Context, fns ...func(context.Context) error) error

Types

type Command

type Command func(*Process) Payload

type Context

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

func (Context) Command

func (ns Context) Command() stream.Command

func (Context) From

func (ns Context) From() stream.CommandType

func (Context) HasNext

func (ns Context) HasNext() bool

func (Context) Proc

func (ns Context) Proc() *Process

func (Context) Reply

func (ns Context) Reply() *stream.Reply

func (Context) To

func (ns Context) To() stream.CommandType

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:"codec"`
	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 Group

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

func New

func New(name string, b commandbus.Replier, o ...Option) *Group

func (*Group) Abort

func (m *Group) Abort(ctx context.Context, pid PID) error

func (*Group) CancelProcess

func (m *Group) CancelProcess(ctx context.Context, pid PID) error

func (*Group) Close

func (m *Group) Close() error

func (*Group) CreateProcess

func (m *Group) CreateProcess(ctx context.Context, pid PID, pc ProcState) error

func (*Group) ErrorHandler

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

func (*Group) NumSteps

func (m *Group) NumSteps() int

func (*Group) OnCancel

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

func (*Group) OnFailure

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

func (*Group) OnSuccess

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

func (*Group) OnSwitchProc

func (m *Group) OnSwitchProc(fn ...SwitchProcFunc)

func (*Group) Run

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

func (*Group) Start

func (m *Group) Start(ctx context.Context, pid PID, pc ProcState) error

func (*Group) StartProcess

func (m *Group) StartProcess(ctx context.Context, pid PID) error

func (*Group) Stream

func (m *Group) Stream(st stream.Type) *Step

type Handler

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

type HookFunc

type HookFunc func(*Process)

type InMemStore

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

func (*InMemStore) Append

func (s *InMemStore) Append(_ context.Context, p *Process) error

func (*InMemStore) Load

func (s *InMemStore) Load(_ context.Context, _ Type, pid PID) (*Process, error)

func (*InMemStore) Remove

func (s *InMemStore) Remove(_ context.Context, pid PID) error

func (*InMemStore) Save

func (s *InMemStore) Save(_ context.Context, p *Process) error

type Logger

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

func NewLogLogger

func NewLogLogger(logger log.Logger) Logger

func NewLogger

func NewLogger(s messaging.Sender, channel string) Logger

func NewNopLogger

func NewNopLogger() Logger

type Middleware

type Middleware func(context.Context, *Process) context.Context

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, gt Type, pid PID) (*Process, error)

Load mocks base method

func (*MockStore) Remove

func (m *MockStore) Remove(ctx context.Context, pid PID) 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, gt, 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 Option

type Option func(*Group)

func Before

func Before(f Middleware) Option

func SetLogger

func SetLogger(l Logger) Option

func SetStore

func SetStore(s Store) Option

type PID

type PID uuid.UUID

func NewPID

func NewPID() PID

func PIDFrom

func PIDFrom(sid stream.ID) PID

func (PID) CorrelationID

func (p PID) CorrelationID() stream.CorrelationID

func (PID) Empty

func (p PID) Empty() bool

func (PID) String

func (p PID) String() string

type Payload

type Payload interface{}

type ProcState

type ProcState map[string]interface{}

func State

func State() ProcState

func (ProcState) Copy

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

func (ProcState) Get

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

func (ProcState) GetBool

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

func (ProcState) GetFloat

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

func (ProcState) GetInt

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

func (ProcState) GetString

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

func (ProcState) Set

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

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(gt Type, pid PID, pc ProcState) *Process

func (*Process) Command

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

func (*Process) CommandType

func (p *Process) CommandType() stream.CommandType

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) PID

func (p *Process) PID() PID

func (*Process) Snapshot

func (p *Process) Snapshot() Snapshot

func (*Process) State

func (p *Process) State() ProcState

func (*Process) Status

func (p *Process) Status() ProcStatus

func (*Process) StatusName

func (p *Process) StatusName() string

func (*Process) StepNum

func (p *Process) StepNum() int

func (*Process) StreamType

func (p *Process) StreamType() stream.Type

func (*Process) Type

func (p *Process) Type() Type

func (*Process) UpdatedAt

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

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
	Reversal   bool
	Err        string
}

type Step

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

func (*Step) Commit

func (t *Step) Commit(ct stream.CommandType, c Command) *Step

func (*Step) Rollback

func (t *Step) Rollback(ct stream.CommandType, c Command) *Step

type Store

type Store interface {
	Append(ctx context.Context, p *Process) error
	Save(ctx context.Context, p *Process) error
	Remove(ctx context.Context, pid PID) error
	Load(ctx context.Context, gt Type, pid PID) (*Process, error)
}

func NewInMemStore

func NewInMemStore() Store

type SwitchProcFunc

type SwitchProcFunc func(Context)

type Type

type Type string

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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