Documentation
¶
Index ¶
- type ErrorFunc
- type ErrorHandler
- type GSInterface
- type GracefulShutdown
- func (gs *GracefulShutdown) AddShutdownCallback(cb ShutdownCallback)
- func (gs *GracefulShutdown) AddShutdownManager(sm ShutdownManager)
- func (gs *GracefulShutdown) GetName() string
- func (gs *GracefulShutdown) ReportError(err error)
- func (gs *GracefulShutdown) SetErrorHandler(eh ErrorHandler)
- func (gs *GracefulShutdown) Start(ctx context.Context) error
- func (gs *GracefulShutdown) StartShutdown()
- type ShutdownCallback
- type ShutdownFunc
- type ShutdownManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorFunc ¶
type ErrorFunc func(error)
ErrorFunc is a type that wraps a function as an ErrorHandler.
func (ErrorFunc) HandleError ¶
HandleError calls the wrapped function as an ErrorHandler.
type ErrorHandler ¶
type ErrorHandler interface {
HandleError(error)
}
ErrorHandler is the interface that defines the callback function that will be executed when an error occurs during the shutdown process.
type GSInterface ¶
type GSInterface interface { Start(context.Context) error AddShutdownManager(ShutdownManager) AddShutdownCallback(ShutdownCallback) SetErrorHandler(ErrorHandler) StartShutdown() ReportError(error) }
GSInterface is the interface that defines the behavior of the GracefulShutdown struct, which is responsible for managing the shutdown process of the application.
type GracefulShutdown ¶
type GracefulShutdown struct {
// contains filtered or unexported fields
}
GracefulShutdown is a struct that implements the GSInterface.
func NewGracefulShutdown ¶
func NewGracefulShutdown(name string) *GracefulShutdown
NewGracefulShutdown creates a new GracefulShutdown with the given name.
func (*GracefulShutdown) AddShutdownCallback ¶
func (gs *GracefulShutdown) AddShutdownCallback(cb ShutdownCallback)
AddShutdownCallback adds a ShutdownCallback to the GracefulShutdown.
func (*GracefulShutdown) AddShutdownManager ¶
func (gs *GracefulShutdown) AddShutdownManager(sm ShutdownManager)
AddShutdownManager adds a ShutdownManager to the GracefulShutdown.
func (*GracefulShutdown) GetName ¶
func (gs *GracefulShutdown) GetName() string
GetName returns the name of the GracefulShutdown.
func (*GracefulShutdown) ReportError ¶
func (gs *GracefulShutdown) ReportError(err error)
ReportError reports an error to the GracefulShutdown.
func (*GracefulShutdown) SetErrorHandler ¶
func (gs *GracefulShutdown) SetErrorHandler(eh ErrorHandler)
SetErrorHandler sets the ErrorHandler of the GracefulShutdown.
func (*GracefulShutdown) Start ¶
func (gs *GracefulShutdown) Start(ctx context.Context) error
Start starts the GracefulShutdown and returns an error if any.
func (*GracefulShutdown) StartShutdown ¶
func (gs *GracefulShutdown) StartShutdown()
StartShutdown begins the shutdown process of the GracefulShutdown.
type ShutdownCallback ¶
type ShutdownCallback interface {
Execute() error
}
ShutdownCallback is the interface that defines the callback function that will be executed when the application is shutting down.
type ShutdownFunc ¶
type ShutdownFunc func() error
ShutdownFunc is a type that wraps a function as a ShutdownCallback.
func (ShutdownFunc) Execute ¶
func (sf ShutdownFunc) Execute() error
Execute calls the wrapped function as a ShutdownCallback.
type ShutdownManager ¶
ShutdownManager is the interface that defines the behavior of a shutdown manager, which is responsible for managing the shutdown process of the application.