Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LifecycleCmd ¶
func LifecycleCmd(fn LifecycleAction) cli.ActionFunc
LifecycleCmd turns a LifecycleAction into an CLI action, by instrumenting it with CLI context and signal based termination. The signals are caught with the opio.BlockFn attached to the context, if any. If no block function is provided, it adds default interrupt handling. The app may continue to run post-processing until fully shutting down. The user can force an early shut-down during post-processing by sending a second interruption signal.
func ProtectFlags ¶
func ProtectFlags(flags []cli.Flag) []cli.Flag
ProtectFlags ensures that no flags are safe to Apply() flag sets to without accidental flag-value mutations. ProtectFlags panics if any of the flag definitions cannot be protected.
Types ¶
type CloneableGeneric ¶
type CloneableGeneric interface {
cli.Generic
Clone() any
}
type Lifecycle ¶
type Lifecycle interface { // Start starts a service. A service only fully starts once. Subsequent starts may return an error. // A context is provided to end the service during setup. // The caller should call Stop to clean up after failing to start. Start(ctx context.Context) error // Stop stops a service gracefully. // The provided ctx can force an accelerated shutdown, // but the node still has to completely stop. Stop(ctx context.Context) error // Stopped determines if the service was stopped with Stop. Stopped() bool }
type LifecycleAction ¶
type LifecycleAction func(ctx *cli.Context, close context.CancelCauseFunc) (Lifecycle, error)
LifecycleAction instantiates a Lifecycle based on a CLI context. With the close argument a lifecycle may choose to shut itself down. A service may choose to idle, dump debug information or otherwise delay a shutdown when the Stop context is not expired.