Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Orchestrate ¶
func Orchestrate(options OrchestrateOptions)
Orchestrate manages the core lifecycle of an application, including startup, shutdown, and os signal handling. StartupCallback is expected to block (e.g., http.Server.ListenAndServe). If it returns immediately, Orchestrate will wait for a shutdown signal before exiting.
Types ¶
type OrchestrateOptions ¶
type OrchestrateOptions struct {
ShutdownTimeout time.Duration // Default: 30 seconds
Signals []os.Signal // Default: SIGHUP, SIGINT, SIGTERM, SIGQUIT
Logger *slog.Logger // Default: os.Stdout
// StartupCallback runs your main application logic (e.g., server.ListenAndServe).
// This callback should block until the application is ready to shut down.
// Do not call os.Exit or log.Fatal here; return an error instead.
StartupCallback func() error
// ShutdownCallback runs cleanup logic (e.g., server.Shutdown, closing DB connections).
// The context has a timeout based on ShutdownTimeout.
// Do not call os.Exit or log.Fatal here; return an error instead.
ShutdownCallback func(context.Context) error
}
Click to show internal directories.
Click to hide internal directories.