lifecycle

package
v0.0.0-...-23becbe Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LifecycleActionContinue = "continue"
	LifecycleActionDone     = "done"

	LifecycleEventError   = "error"
	LifecycleEventStop    = "stop"
	LifecycleEventSuccess = "success"
	LifecycleEventDone    = "done"
	LifecycleEventStart   = "start"
	LifecycleEventPause   = "pause"

	LifecycleStateInit = "init"
	LifecycleStateDone = "done"

	LifecycleOnStopped               domain.Event = "loop_stopped"
	LifecycleOnFinishedActionHandler domain.Event = "action_handler_finished"
	LifecycleOnFinishedLoop          domain.Event = "loop_finished"
	LifecycleOnStateChanged          domain.Event = "state_changed"
	LifecycleOnHistoryRecorded       domain.Event = "history_recorded"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Current

type Current struct {
	PID       string
	RequestID string
	State     state.State
	Action    action.Action
	Event     string
	Payload   interface{}
	Error     error
}

type History

type History struct {
	*core.Component
	// contains filtered or unexported fields
}

func NewHistory

func NewHistory() *History

func (*History) GetAll

func (h *History) GetAll() []HistoryNode

func (*History) GetFirst

func (h *History) GetFirst() (HistoryNode, error)

func (*History) GetLast

func (h *History) GetLast() (HistoryNode, error)

func (*History) GetNext

func (h *History) GetNext(historyUID string) (HistoryNode, error)

func (*History) GetPrev

func (h *History) GetPrev(historyUID string) (HistoryNode, error)

func (*History) GetRecord

func (h *History) GetRecord(historyUID string) (HistoryNode, error)

func (*History) IsHistoryExist

func (h *History) IsHistoryExist(historyUID string) bool

func (*History) Record

func (h *History) Record(current HistoryNode)

func (*History) TotalRecord

func (h *History) TotalRecord() int

type HistoryNode

type HistoryNode struct {
	*core.Component
	// contains filtered or unexported fields
}

func NewHistoryNode

func NewHistoryNode(uidgen uid.UUID, current Current) (HistoryNode, error)

func (HistoryNode) GetState

func (hn HistoryNode) GetState() Current

func (HistoryNode) GetUID

func (hn HistoryNode) GetUID() string

type Lifecycle

type Lifecycle struct {
	*core.Component
	domain.Aggregate
	// contains filtered or unexported fields
}

func NewLifecycle

func NewLifecycle(pid, requestID string, uidgen uid.UUID, query metadata.QueryBuilder, handler runner.RunnerBuilder) *Lifecycle

func (*Lifecycle) GetHistory

func (l *Lifecycle) GetHistory() *History

func (*Lifecycle) GetLatestState

func (l *Lifecycle) GetLatestState() (HistoryNode, error)

func (*Lifecycle) Loop

func (l *Lifecycle) Loop(ctx context.Context)

func (*Lifecycle) Start

func (l *Lifecycle) Start(payload interface{})

func (*Lifecycle) StartWith

func (l *Lifecycle) StartWith(s state.State, event string, payload interface{})

func (*Lifecycle) Stop

func (l *Lifecycle) Stop()

type LifecycleBuilder

type LifecycleBuilder interface {
	GetHistory() *History
	GetLatestState() (HistoryNode, error)
	StartWith(s state.State, event string, payload interface{})
	Start(payload interface{})
	Loop(ctx context.Context)
	Stop()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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