Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
type Hook struct { OnStart func(context.Context) error OnStop func(context.Context) error // contains filtered or unexported fields }
A Hook is a pair of start and stop callbacks, either of which can be nil, plus a string identifying the supplier of the hook.
type HookRecord ¶ added in v1.14.0
type HookRecord struct { CallerFrame fxreflect.Frame // stack frame of the caller Func func(context.Context) error // function that ran as sanitized name Runtime time.Duration // how long the hook ran }
HookRecord keeps track of each Hook's execution time, the caller that appended the Hook, and function that ran as the Hook.
type HookRecords ¶ added in v1.14.0
type HookRecords []HookRecord
HookRecords is a Stringer wrapper of HookRecord slice.
func (HookRecords) Format ¶ added in v1.14.0
func (rs HookRecords) Format(w fmt.State, c rune)
Format implements fmt.Formatter to handle "%+v".
func (HookRecords) Len ¶ added in v1.14.0
func (rs HookRecords) Len() int
func (HookRecords) Less ¶ added in v1.14.0
func (rs HookRecords) Less(i, j int) bool
func (HookRecords) String ¶ added in v1.14.0
func (rs HookRecords) String() string
Used for logging startup errors.
func (HookRecords) Swap ¶ added in v1.14.0
func (rs HookRecords) Swap(i, j int)
type Lifecycle ¶
type Lifecycle struct {
// contains filtered or unexported fields
}
Lifecycle coordinates application lifecycle hooks.
func (*Lifecycle) RunningHookCaller ¶ added in v1.14.0
RunningHookCaller returns the name of the hook that was running when a Start/Stop hook timed out.
func (*Lifecycle) Start ¶
Start runs all OnStart hooks, returning immediately if it encounters an error.
func (*Lifecycle) StartHookRecords ¶ added in v1.14.0
func (l *Lifecycle) StartHookRecords() HookRecords
StartHookRecords returns the info of OnStart hooks that successfully ran till the end, including their caller and runtime. Used to report timeout errors on Start.
func (*Lifecycle) Stop ¶
Stop runs any OnStop hooks whose OnStart counterpart succeeded. OnStop hooks run in reverse order.
func (*Lifecycle) StopHookRecords ¶ added in v1.14.0
func (l *Lifecycle) StopHookRecords() HookRecords
StopHookRecords returns the info of OnStop hooks that successfully ran till the end, including their caller and runtime. Used to report timeout errors on Stop.