Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callable ¶ added in v1.19.0
type Callable interface { ~Func | ~ErrorFunc | ~ContextFunc | ~ContextErrorFunc }
A Callable is a constraint that matches functions that are, or can be converted to, functions suitable for a Hook.
Callable must be identical to [fx.HookFunc].
type ContextErrorFunc ¶ added in v1.19.0
A ContextErrorFunc is used as a [Hook.OnStart] or [Hook.OnStop] function.
func Wrap ¶ added in v1.19.0
func Wrap[T Callable](x T) (ContextErrorFunc, string)
Wrap wraps x into a ContextErrorFunc suitable for a Hook.
type ContextFunc ¶ added in v1.19.0
A ContextFunc can be converted to a ContextErrorFunc.
type ErrorFunc ¶ added in v1.19.0
type ErrorFunc = func() error
An ErrorFunc can be converted to a ContextErrorFunc.
type Hook ¶
type Hook struct { OnStart func(context.Context) error OnStop func(context.Context) error OnStartName string OnStopName string // 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.