Documentation
¶
Index ¶
- Constants
- Variables
- func AddClosedFuture[FUTURE Future[error]](lifecycle Lifecycle, future FUTURE) FUTURE
- func AddRunningFuture[FUTURE Future[error]](lifecycle Lifecycle, future FUTURE) FUTURE
- func GetField[V any](l Lifecycle, name string) (v V)
- func InterrupterHoldRun(_ Lifecycle, interrupter chan struct{}) error
- func RemoveField[V any](l Lifecycle, name string) (v V)
- func SetDefaultField[V any](l Lifecycle, name string, defaultValue V) (value V, exist bool)
- type CallbackFuture
- type ChanFuture
- type CloseFunc
- type DefaultLifecycle
- func New(options ...Option) *DefaultLifecycle
- func NewWithInterruptedRun(startFn InterruptedStartFunc, runFn InterruptedRunFunc, options ...Option) *DefaultLifecycle
- func NewWithInterruptedRunner(runner InterruptedRunner, options ...Option) *DefaultLifecycle
- func NewWithInterruptedStart(starterFn InterruptedStarterFunc, options ...Option) *DefaultLifecycle
- func NewWithInterruptedStarter(starter InterruptedStarter, options ...Option) *DefaultLifecycle
- func NewWithRun(startFn StartFunc, runFn RunFunc, closeFn CloseFunc, options ...Option) *DefaultLifecycle
- func NewWithRunner(runner Runner, options ...Option) *DefaultLifecycle
- func NewWithStart(starterFn StarterFunc, options ...Option) *DefaultLifecycle
- func NewWithStarter(starter Starter, options ...Option) *DefaultLifecycle
- func (l *DefaultLifecycle) AddClosedFuture(future Future[error]) Future[error]
- func (l *DefaultLifecycle) AddStartedFuture(future Future[error]) Future[error]
- func (l *DefaultLifecycle) Background() error
- func (l *DefaultLifecycle) Close(future Future[error]) error
- func (l *DefaultLifecycle) ClosedWaiter() <-chan error
- func (l *DefaultLifecycle) DeleteField(name string) Lifecycle
- func (l *DefaultLifecycle) Error() error
- func (l *DefaultLifecycle) Field(name string) (value any)
- func (l *DefaultLifecycle) Fields() map[string]any
- func (l *DefaultLifecycle) OnClose(onClose OnCloseFunc) Lifecycle
- func (l *DefaultLifecycle) OnClosed(onClosed OnClosedFunc) Lifecycle
- func (l *DefaultLifecycle) OnStarted(onStarted OnStartedFunc) Lifecycle
- func (l *DefaultLifecycle) OnStarting(onStarting OnStartingFunc) Lifecycle
- func (l *DefaultLifecycle) RangeField(f func(name string, value any) bool) Lifecycle
- func (l *DefaultLifecycle) RemoveField(name string) (value any)
- func (l *DefaultLifecycle) Run() error
- func (l *DefaultLifecycle) SetDefaultField(name string, defaultValue any) (value any, exist bool)
- func (l *DefaultLifecycle) SetField(name string, value any) Lifecycle
- func (l *DefaultLifecycle) SetOnClose(onClose OnCloseFunc) Lifecycle
- func (l *DefaultLifecycle) SetOnClosed(onClosed OnClosedFunc) Lifecycle
- func (l *DefaultLifecycle) SetOnStarted(onStarted OnStartedFunc) Lifecycle
- func (l *DefaultLifecycle) SetOnStarting(onStarting OnStartingFunc) Lifecycle
- func (l *DefaultLifecycle) Shutdown() error
- func (l *DefaultLifecycle) Start() error
- func (l *DefaultLifecycle) StartedWaiter() <-chan error
- func (l *DefaultLifecycle) String() string
- type Future
- type Futures
- type Group
- type GroupLifecycleHolder
- func (h *GroupLifecycleHolder) Group() *Group
- func (h *GroupLifecycleHolder) Name() string
- func (h *GroupLifecycleHolder) SetCloseAllOnExit(enable bool) *GroupLifecycleHolder
- func (h *GroupLifecycleHolder) SetCloseAllOnExitError(enable bool) *GroupLifecycleHolder
- func (h *GroupLifecycleHolder) SetCloseAllOnStartError(enable bool) *GroupLifecycleHolder
- type InterruptedError
- type InterruptedRunFunc
- type InterruptedRunner
- type InterruptedStartFunc
- type InterruptedStarter
- type InterruptedStarterFunc
- type Lifecycle
- type List
- type ListLifecycleHolder
- func (h *ListLifecycleHolder) List() *List
- func (h *ListLifecycleHolder) SetCloseAllOnExit(enable bool) *ListLifecycleHolder
- func (h *ListLifecycleHolder) SetCloseAllOnExitError(enable bool) *ListLifecycleHolder
- func (h *ListLifecycleHolder) SetCloseAllOnStartError(enable bool) *ListLifecycleHolder
- func (h *ListLifecycleHolder) SetCloseBackOnExit(enable bool) *ListLifecycleHolder
- func (h *ListLifecycleHolder) SetCloseBackOnExitError(enable bool) *ListLifecycleHolder
- func (h *ListLifecycleHolder) SetStopStartOnStartError(enable bool) *ListLifecycleHolder
- type NopFuture
- type OnCloseFunc
- type OnClosedFunc
- type OnStartedFunc
- type OnStartingFunc
- type Option
- type Retryable
- type RunFunc
- type Runner
- type StartFunc
- type Starter
- type StarterFunc
- type State
- type StateClosedError
- type StateClosingError
- type StateConflictError
- type StateDependencyError
- type StateInfo
- type StateMustSwitchError
- type StateNotAllowSwitchError
- type StateNotClosedError
- type StateNotRunningError
- type StateRunningError
- type StateStartingError
- type SyncFutures
- type UnknownStateError
- type WaitableFuture
- type WaiterFuture
Constants ¶
View Source
const ( StateClosed = State(iota) StateStarting StateRunning StateClosing )
View Source
const GroupFieldName = "$group"
View Source
const ListFieldName = "$list"
View Source
const RetryableFieldName = "$retryable"
Variables ¶
View Source
var StateInfos = []StateInfo{ {State: StateClosed, UpperName: "CLOSED"}, {State: StateStarting, UpperName: "STARTING"}, {State: StateRunning, UpperName: "RUNNING"}, {State: StateClosing, UpperName: "CLOSING"}, }
Functions ¶
func AddClosedFuture ¶
func AddRunningFuture ¶
func InterrupterHoldRun ¶
func RemoveField ¶
Types ¶
type CallbackFuture ¶
type CallbackFuture[V any] struct { // contains filtered or unexported fields }
func NewCallbackFuture ¶
func NewCallbackFuture[V any](callback func(value V)) *CallbackFuture[V]
func (CallbackFuture[V]) Complete ¶
func (f CallbackFuture[V]) Complete(value V)
func (CallbackFuture[V]) SetCallback ¶
func (f CallbackFuture[V]) SetCallback(callback func(value V))
type ChanFuture ¶
type ChanFuture[V any] chan V
func (ChanFuture[V]) Complete ¶
func (c ChanFuture[V]) Complete(value V)
func (ChanFuture[V]) Wait ¶
func (c ChanFuture[V]) Wait() V
type DefaultLifecycle ¶
func New ¶
func New(options ...Option) *DefaultLifecycle
func NewWithInterruptedRun ¶
func NewWithInterruptedRun(startFn InterruptedStartFunc, runFn InterruptedRunFunc, options ...Option) *DefaultLifecycle
func NewWithInterruptedRunner ¶
func NewWithInterruptedRunner(runner InterruptedRunner, options ...Option) *DefaultLifecycle
func NewWithInterruptedStart ¶
func NewWithInterruptedStart(starterFn InterruptedStarterFunc, options ...Option) *DefaultLifecycle
func NewWithInterruptedStarter ¶
func NewWithInterruptedStarter(starter InterruptedStarter, options ...Option) *DefaultLifecycle
func NewWithRun ¶
func NewWithRun(startFn StartFunc, runFn RunFunc, closeFn CloseFunc, options ...Option) *DefaultLifecycle
func NewWithRunner ¶
func NewWithRunner(runner Runner, options ...Option) *DefaultLifecycle
func NewWithStart ¶
func NewWithStart(starterFn StarterFunc, options ...Option) *DefaultLifecycle
func NewWithStarter ¶
func NewWithStarter(starter Starter, options ...Option) *DefaultLifecycle
func (*DefaultLifecycle) AddClosedFuture ¶
func (l *DefaultLifecycle) AddClosedFuture(future Future[error]) Future[error]
func (*DefaultLifecycle) AddStartedFuture ¶
func (l *DefaultLifecycle) AddStartedFuture(future Future[error]) Future[error]
func (*DefaultLifecycle) Background ¶
func (l *DefaultLifecycle) Background() error
func (*DefaultLifecycle) ClosedWaiter ¶
func (l *DefaultLifecycle) ClosedWaiter() <-chan error
func (*DefaultLifecycle) DeleteField ¶
func (l *DefaultLifecycle) DeleteField(name string) Lifecycle
func (*DefaultLifecycle) Error ¶
func (l *DefaultLifecycle) Error() error
func (*DefaultLifecycle) Field ¶
func (l *DefaultLifecycle) Field(name string) (value any)
func (*DefaultLifecycle) Fields ¶
func (l *DefaultLifecycle) Fields() map[string]any
func (*DefaultLifecycle) OnClose ¶
func (l *DefaultLifecycle) OnClose(onClose OnCloseFunc) Lifecycle
func (*DefaultLifecycle) OnClosed ¶
func (l *DefaultLifecycle) OnClosed(onClosed OnClosedFunc) Lifecycle
func (*DefaultLifecycle) OnStarted ¶
func (l *DefaultLifecycle) OnStarted(onStarted OnStartedFunc) Lifecycle
func (*DefaultLifecycle) OnStarting ¶
func (l *DefaultLifecycle) OnStarting(onStarting OnStartingFunc) Lifecycle
func (*DefaultLifecycle) RangeField ¶
func (l *DefaultLifecycle) RangeField(f func(name string, value any) bool) Lifecycle
func (*DefaultLifecycle) RemoveField ¶
func (l *DefaultLifecycle) RemoveField(name string) (value any)
func (*DefaultLifecycle) Run ¶
func (l *DefaultLifecycle) Run() error
func (*DefaultLifecycle) SetDefaultField ¶
func (l *DefaultLifecycle) SetDefaultField(name string, defaultValue any) (value any, exist bool)
func (*DefaultLifecycle) SetField ¶
func (l *DefaultLifecycle) SetField(name string, value any) Lifecycle
func (*DefaultLifecycle) SetOnClose ¶
func (l *DefaultLifecycle) SetOnClose(onClose OnCloseFunc) Lifecycle
func (*DefaultLifecycle) SetOnClosed ¶
func (l *DefaultLifecycle) SetOnClosed(onClosed OnClosedFunc) Lifecycle
func (*DefaultLifecycle) SetOnStarted ¶
func (l *DefaultLifecycle) SetOnStarted(onStarted OnStartedFunc) Lifecycle
func (*DefaultLifecycle) SetOnStarting ¶
func (l *DefaultLifecycle) SetOnStarting(onStarting OnStartingFunc) Lifecycle
func (*DefaultLifecycle) Shutdown ¶
func (l *DefaultLifecycle) Shutdown() error
func (*DefaultLifecycle) Start ¶
func (l *DefaultLifecycle) Start() error
func (*DefaultLifecycle) StartedWaiter ¶
func (l *DefaultLifecycle) StartedWaiter() <-chan error
func (*DefaultLifecycle) String ¶
func (l *DefaultLifecycle) String() string
type Group ¶
type Group struct { Lifecycle // contains filtered or unexported fields }
func (*Group) Add ¶
func (g *Group) Add(name string, lifecycle Lifecycle) (*GroupLifecycleHolder, error)
func (*Group) MustAdd ¶
func (g *Group) MustAdd(name string, lifecycle Lifecycle) *GroupLifecycleHolder
func (*Group) Remove ¶
func (g *Group) Remove(name string) *GroupLifecycleHolder
type GroupLifecycleHolder ¶
type GroupLifecycleHolder struct { Lifecycle // contains filtered or unexported fields }
func (*GroupLifecycleHolder) Group ¶
func (h *GroupLifecycleHolder) Group() *Group
func (*GroupLifecycleHolder) Name ¶
func (h *GroupLifecycleHolder) Name() string
func (*GroupLifecycleHolder) SetCloseAllOnExit ¶
func (h *GroupLifecycleHolder) SetCloseAllOnExit(enable bool) *GroupLifecycleHolder
func (*GroupLifecycleHolder) SetCloseAllOnExitError ¶
func (h *GroupLifecycleHolder) SetCloseAllOnExitError(enable bool) *GroupLifecycleHolder
func (*GroupLifecycleHolder) SetCloseAllOnStartError ¶
func (h *GroupLifecycleHolder) SetCloseAllOnStartError(enable bool) *GroupLifecycleHolder
type InterruptedError ¶
func NewInterruptedError ¶
func NewInterruptedError(target string, action string) *InterruptedError
func (*InterruptedError) Error ¶
func (e *InterruptedError) Error() string
type InterruptedRunFunc ¶
type InterruptedRunner ¶
type InterruptedRunner interface { DoStart(lifecycle Lifecycle, interrupter chan struct{}) error DoRun(lifecycle Lifecycle, interrupter chan struct{}) error }
func FuncInterruptedRunner ¶
func FuncInterruptedRunner(startFn InterruptedStartFunc, runFn InterruptedRunFunc) InterruptedRunner
type InterruptedStartFunc ¶
type InterruptedStarter ¶
type InterruptedStarter interface {
DoStart(lifecycle Lifecycle, interrupter chan struct{}) (runFn InterruptedRunFunc, err error)
}
func FuncInterruptedStarter ¶
func FuncInterruptedStarter(starterFn InterruptedStarterFunc) InterruptedStarter
type InterruptedStarterFunc ¶
type InterruptedStarterFunc = func(lifecycle Lifecycle, interrupter chan struct{}) (runFn InterruptedRunFunc, err error)
type Lifecycle ¶
type Lifecycle interface { Run() error Background() error Start() error StartedWaiter() <-chan error Close(future Future[error]) error ClosedWaiter() <-chan error Shutdown() error AddStartedFuture(future Future[error]) Future[error] AddClosedFuture(future Future[error]) Future[error] OnStarting(OnStartingFunc) Lifecycle OnStarted(OnStartedFunc) Lifecycle OnClose(OnCloseFunc) Lifecycle OnClosed(OnClosedFunc) Lifecycle SetOnStarting(OnStartingFunc) Lifecycle SetOnStarted(OnStartedFunc) Lifecycle SetOnClose(OnCloseFunc) Lifecycle SetOnClosed(OnClosedFunc) Lifecycle Field(name string) any Fields() map[string]any SetField(name string, value any) Lifecycle SetDefaultField(name string, defaultValue any) (value any, exist bool) DeleteField(name string) Lifecycle RemoveField(name string) any RangeField(f func(name string, value any) bool) Lifecycle Error() error }
type List ¶
type List struct { Lifecycle // contains filtered or unexported fields }
func (*List) MustAppend ¶
func (l *List) MustAppend(lifecycle Lifecycle) *ListLifecycleHolder
type ListLifecycleHolder ¶
type ListLifecycleHolder struct { Lifecycle // contains filtered or unexported fields }
func (*ListLifecycleHolder) List ¶
func (h *ListLifecycleHolder) List() *List
func (*ListLifecycleHolder) SetCloseAllOnExit ¶
func (h *ListLifecycleHolder) SetCloseAllOnExit(enable bool) *ListLifecycleHolder
func (*ListLifecycleHolder) SetCloseAllOnExitError ¶
func (h *ListLifecycleHolder) SetCloseAllOnExitError(enable bool) *ListLifecycleHolder
func (*ListLifecycleHolder) SetCloseAllOnStartError ¶
func (h *ListLifecycleHolder) SetCloseAllOnStartError(enable bool) *ListLifecycleHolder
func (*ListLifecycleHolder) SetCloseBackOnExit ¶
func (h *ListLifecycleHolder) SetCloseBackOnExit(enable bool) *ListLifecycleHolder
func (*ListLifecycleHolder) SetCloseBackOnExitError ¶
func (h *ListLifecycleHolder) SetCloseBackOnExitError(enable bool) *ListLifecycleHolder
func (*ListLifecycleHolder) SetStopStartOnStartError ¶
func (h *ListLifecycleHolder) SetStopStartOnStartError(enable bool) *ListLifecycleHolder
type OnCloseFunc ¶
type OnClosedFunc ¶
type OnStartedFunc ¶
type OnStartingFunc ¶
type OnStartingFunc = func(Lifecycle)
type Option ¶
type Option interface {
Apply(lifecycle Lifecycle)
}
func WithInterruptedRunner ¶
func WithInterruptedRunner(runner InterruptedRunner) Option
func WithInterruptedStarter ¶
func WithInterruptedStarter(starter InterruptedStarter) Option
func WithRunner ¶
func WithStarter ¶
type Runner ¶
func FuncRunner ¶
type Starter ¶
func FuncStarter ¶
func FuncStarter(starterFn StarterFunc) Starter
type StateClosedError ¶
type StateClosedError struct {
Target string
}
func NewStateClosedError ¶
func NewStateClosedError(target string) *StateClosedError
func (*StateClosedError) Error ¶
func (e *StateClosedError) Error() string
type StateClosingError ¶
type StateClosingError struct {
Target string
}
func NewStateClosingError ¶
func NewStateClosingError(target string) *StateClosingError
func (*StateClosingError) Error ¶
func (e *StateClosingError) Error() string
type StateConflictError ¶
func NewStateConflictError ¶
func NewStateConflictError(target string, state string, conflict string) *StateConflictError
func (*StateConflictError) Error ¶
func (e *StateConflictError) Error() string
type StateDependencyError ¶
func NewStateDependencyError ¶
func NewStateDependencyError(target string, state string, depend string) *StateDependencyError
func (*StateDependencyError) Error ¶
func (e *StateDependencyError) Error() string
type StateMustSwitchError ¶
func NewStateMustSwitchError ¶
func NewStateMustSwitchError(target string, from string, to string) *StateMustSwitchError
func (*StateMustSwitchError) Error ¶
func (e *StateMustSwitchError) Error() string
type StateNotAllowSwitchError ¶
func NewStateNotAllowSwitchError ¶
func NewStateNotAllowSwitchError(target string, from string, to string) *StateNotAllowSwitchError
func (*StateNotAllowSwitchError) Error ¶
func (e *StateNotAllowSwitchError) Error() string
type StateNotClosedError ¶
type StateNotClosedError struct {
Target string
}
func NewStateNotClosedError ¶
func NewStateNotClosedError(target string) *StateNotClosedError
func (*StateNotClosedError) Error ¶
func (e *StateNotClosedError) Error() string
type StateNotRunningError ¶
type StateNotRunningError struct {
Target string
}
func NewStateNotRunningError ¶
func NewStateNotRunningError(target string) *StateNotRunningError
func (*StateNotRunningError) Error ¶
func (e *StateNotRunningError) Error() string
type StateRunningError ¶
type StateRunningError struct {
Target string
}
func NewStateRunningError ¶
func NewStateRunningError(target string) *StateRunningError
func (*StateRunningError) Error ¶
func (e *StateRunningError) Error() string
type StateStartingError ¶
type StateStartingError struct {
Target string
}
func NewStateStartingError ¶
func NewStateStartingError(target string) *StateStartingError
func (*StateStartingError) Error ¶
func (e *StateStartingError) Error() string
type SyncFutures ¶
func NewSyncFutures ¶
func NewSyncFutures[V any]() *SyncFutures[V]
func (*SyncFutures[V]) Append ¶
func (f *SyncFutures[V]) Append(future Future[V])
func (*SyncFutures[V]) LoadAndReset ¶
func (f *SyncFutures[V]) LoadAndReset() Futures[V]
type UnknownStateError ¶
func NewUnknownStateError ¶
func NewUnknownStateError(target string, state State) *UnknownStateError
func (*UnknownStateError) Error ¶
func (e *UnknownStateError) Error() string
type WaitableFuture ¶
type WaiterFuture ¶
type WaiterFuture[V any] struct { // contains filtered or unexported fields }
func NewWaiterFuture ¶
func NewWaiterFuture[V any]() *WaiterFuture[V]
func (*WaiterFuture[V]) Complete ¶
func (w *WaiterFuture[V]) Complete(value V)
func (*WaiterFuture[V]) Wait ¶
func (w *WaiterFuture[V]) Wait() V
Source Files
¶
Click to show internal directories.
Click to hide internal directories.