Documentation
¶
Index ¶
- Constants
- Variables
- func Catch(f func()) (err error)
- func Finish(ctx context.Context, s System)
- func IsFinished(ctx context.Context) bool
- func MustConfigure(s System)
- func MustExecActions(ctx context.Context, s System, cmd interface{}) context.Context
- func MustReady(s System)
- func MustStart(s System)
- func MustStop(s System)
- func NopReveiver(context.Context, System)
- func PanicIfNotInStage(s System, stage Stage)
- func WithFinished(ctx context.Context) context.Context
- type Action
- func CreateAction(cmd interface{}, p Process) *Action
- func CreateStartAction(p Process) *Action
- func CreateStopAction(p Process) *Action
- func NewAction() *Action
- func WrapStartAction(h func()) *Action
- func WrapStartOrPanicAction(h func() error) *Action
- func WrapStopAction(h func()) *Action
- func WrapStopOrPanicAction(h func() error) *Action
- type BasicSystem
- func (s *BasicSystem) GetSystemActions(cmd interface{}) []Process
- func (s *BasicSystem) LogSystemError(err error)
- func (s *BasicSystem) MountSystemActions(actions ...*Action)
- func (s *BasicSystem) MustRegisterSystemModule(m Module)
- func (s *BasicSystem) ResetSystem()
- func (s *BasicSystem) SetSystemLogger(l func(error))
- func (s *BasicSystem) SetSystemStage(stage Stage)
- func (s *BasicSystem) SystemContext() context.Context
- func (s *BasicSystem) SystemModules() []Module
- func (s *BasicSystem) SystemStage() Stage
- type Command
- type ContextKey
- type Errors
- type Module
- type NopModule
- type Process
- type Stage
- type System
Constants ¶
View Source
const CommandStart = Command("start")
View Source
const CommandStop = Command("stop")
View Source
const ContextKeyFinished = ContextKey("finished")
Variables ¶
View Source
var DefaultLogger = func(err error) { log.Println(err.Error()) }
View Source
var ErrInvalidStage = errors.New("invalid stage")
View Source
var ErrModuleNameDuplicated = errors.New("module name duplicated")
View Source
var StageNames = map[Stage]string{ StageNew: "New", StageReady: "Ready", StageConfiguring: "Configuring", StageStarting: "Starting", StageRunning: "Running", StageStoping: "Stoping", }
Functions ¶
func IsFinished ¶
func MustConfigure ¶
func MustConfigure(s System)
func MustExecActions ¶
func NopReveiver ¶
func PanicIfNotInStage ¶
Types ¶
type Action ¶
type Action struct {
Command interface{}
Process Process
}
func CreateAction ¶
func CreateStartAction ¶
func CreateStopAction ¶
func WrapStartAction ¶
func WrapStartAction(h func()) *Action
func WrapStartOrPanicAction ¶
func WrapStopAction ¶
func WrapStopAction(h func()) *Action
func WrapStopOrPanicAction ¶
type BasicSystem ¶
type BasicSystem struct {
// contains filtered or unexported fields
}
func New ¶
func New() *BasicSystem
func (*BasicSystem) GetSystemActions ¶
func (s *BasicSystem) GetSystemActions(cmd interface{}) []Process
func (*BasicSystem) LogSystemError ¶
func (s *BasicSystem) LogSystemError(err error)
func (*BasicSystem) MountSystemActions ¶
func (s *BasicSystem) MountSystemActions(actions ...*Action)
func (*BasicSystem) MustRegisterSystemModule ¶
func (s *BasicSystem) MustRegisterSystemModule(m Module)
func (*BasicSystem) ResetSystem ¶
func (s *BasicSystem) ResetSystem()
func (*BasicSystem) SetSystemLogger ¶
func (s *BasicSystem) SetSystemLogger(l func(error))
func (*BasicSystem) SetSystemStage ¶
func (s *BasicSystem) SetSystemStage(stage Stage)
func (*BasicSystem) SystemContext ¶
func (s *BasicSystem) SystemContext() context.Context
func (*BasicSystem) SystemModules ¶
func (s *BasicSystem) SystemModules() []Module
func (*BasicSystem) SystemStage ¶
func (s *BasicSystem) SystemStage() Stage
type ContextKey ¶
type ContextKey string
type Errors ¶
func (*Errors) NilOrError ¶
type Module ¶
type Module interface {
ModuleName() string
InitModule()
InstallProcess(ctx context.Context, system System, next func(context.Context, System))
}
type NopModule ¶
type NopModule struct {
}
func (NopModule) InitModule ¶
func (NopModule) InitModule()
func (NopModule) InstallProcess ¶
func (NopModule) ModuleName ¶
type System ¶
type System interface {
SystemStage() Stage
SetSystemStage(stage Stage)
SystemModules() []Module
MustRegisterSystemModule(m Module)
GetSystemActions(cmd interface{}) []Process
MountSystemActions(actions ...*Action)
ResetSystem()
SystemContext() context.Context
SetSystemLogger(func(error))
LogSystemError(error)
}
Click to show internal directories.
Click to hide internal directories.