package lifecycle
Import Path
go.uber.org/fx/internal/lifecycle (on go.dev)
Dependency Relation
imports 12 packages, and imported by one package
Involved Source Files
lifecycle.go
Package-Level Type Names (total 9)
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].
A ContextErrorFunc is used as a [Hook.OnStart] or [Hook.OnStop]
function.
A ContextFunc can be converted to a ContextErrorFunc.
An ErrorFunc can be converted to a ContextErrorFunc.
A Func can be converted to a ContextErrorFunc.
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.
OnStart func(context.Context) error
OnStartName string
OnStop func(context.Context) error
OnStopName string
func (*Lifecycle).Append(hook Hook)
HookRecord keeps track of each Hook's execution time, the caller that appended the Hook, and function that ran as the Hook.
// stack frame of the caller
// function that ran as sanitized name
// how long the hook ran
HookRecords is a Stringer wrapper of HookRecord slice.
Format implements fmt.Formatter to handle "%+v".
( HookRecords) Len() int
( HookRecords) Less(i, j int) bool
Used for logging startup errors.
( HookRecords) Swap(i, j int)
HookRecords : expvar.Var
HookRecords : fmt.Formatter
HookRecords : fmt.Stringer
HookRecords : sort.Interface
Lifecycle coordinates application lifecycle hooks.
Append adds a Hook to the lifecycle.
RunningHookCaller returns the name of the hook that was running when a Start/Stop
hook timed out.
Start runs all OnStart hooks, returning immediately if it encounters an
error.
Stop runs any OnStop hooks whose OnStart counterpart succeeded. OnStop
hooks run in reverse order.
func New(logger fxevent.Logger, clock fxclock.Clock) *Lifecycle
Package-Level Functions (total 2)
New constructs a new Lifecycle.
Type Parameters:
T: Callable
Wrap wraps x into a ContextErrorFunc suitable for a Hook.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |