Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) IsRunning ¶ added in v4.0.5
IsRunning returns whether the application is currently running
type AppEvent ¶ added in v4.3.7
type AppEvent interface {
// Order returns the order of the event.
// Lower numbers indicate higher priority.
Order() int
}
AppEvent is the base interface for all app events.
type ConfigEvent ¶ added in v4.1.0
type ConfigEvent interface {
AppEvent
// OnConfigLoaded is called after all configuration files have been successfully loaded.
OnConfigLoaded(cp config.Provider)
}
ConfigEvent is the interface for events related to configuration loading.
type ContainerRefreshAfterEvent ¶
type ContainerRefreshAfterEvent interface {
AppEvent
// OnContainerRefreshAfter is called after the IoC container has completed its refresh process.
// At this point, all beans have been created, dependencies injected, and the container is ready for use.
// This is the ideal place to perform post-refresh tasks such as:
//
// - Validating bean initialization results
// - Performing cross-bean validations
// - Starting background services that depend on beans
// - Logging container status and statistics
// - Triggering application-specific initialization logic
//
// Note: The container state should not be modified at this point.
OnContainerRefreshAfter()
}
ContainerRefreshAfterEvent is called after the IoC container refresh process. Implement this interface to perform post-refresh tasks.
type ContainerRefreshBeforeEvent ¶
type ContainerRefreshBeforeEvent interface {
AppEvent
// OnContainerRefreshBefore is called before the IoC container begins its refresh process.
// This is the ideal place to perform container preparation tasks such as:
//
// - Registering additional bean definitions
// - Registering pre-configured bean instances
// - Modifying container configuration
// - Performing pre-refresh validations
// - Setting up custom bean processors
OnContainerRefreshBefore()
}
ContainerRefreshBeforeEvent is called before the IoC container refresh process. Implement this interface to perform container preparation tasks.
type Option ¶
type Option func(app *App)
Option defines a function type for configuring App instances. This follows the functional options pattern, allowing flexible and extensible configuration during App creation via the New() function.
func WithBanner ¶
WithBanner sets a custom banner for the application.
func WithConfigProvider ¶ added in v4.0.5
WithConfigProvider sets the application's configuration provider. If not specified, the default provider will be used. Note: Calling this multiple times will overwrite the previous provider.
func WithEvent ¶
WithEvent registers application lifecycle events. Events are managed by the event manager and triggered during app lifecycle.
func WithLogger ¶
WithLogger sets a custom log for the application. The log function receives the application configuration and should return a configured log instance. This allows the log to be configured based on the loaded configuration settings.
Note: Calling this multiple times will overwrite the previous provider.
func WithMiddleware ¶
func WithMiddleware(middlewares ...gin.HandlerFunc) Option
WithMiddleware registers Gin middlewares to the application. Middlewares are executed in the order they are added.
type RunMode ¶ added in v4.0.5
type RunMode int
RunMode defines the application's running mode.
const ( // InitializeMode initializes configuration and logger only. // Useful for configuration validation or testing. InitializeMode RunMode = iota // ContainerMode extends InitializeMode by creating and injecting dependencies // into the container, while keeping the HTTP server inactive. ContainerMode // ServerMode fully operational mode where the application starts the HTTP server // after completing all initializations. ServerMode )
type ShutdownSignal ¶ added in v4.4.6
type ShutdownSignal interface {
// Done returns a receive-only channel that is closed when the application
// starts shutting down.
Done() <-chan struct{}
}
ShutdownSignal exposes an application-level shutdown notification. Long-lived handlers and workers can listen on Done to exit before the HTTP server waits for all active requests to complete.
type StartedEvent ¶ added in v4.1.3
type StartedEvent interface {
AppEvent
// OnStarted is called after the application has started successfully.
// Use this method to perform post-start tasks, such as:
// - Starting background workers or schedulers
// - Sending startup notifications
// - Performing warm-up operations
// - Logging startup completion status
// - Triggering external system notifications
// Note: At this point, the HTTP server is running and ready to accept requests.
OnStarted()
}
StartedEvent is called after the application has started successfully. Implement this interface to perform post-start tasks.
type StartingEvent ¶ added in v4.1.3
type StartingEvent interface {
AppEvent
// OnStarting is called before the application starts.
// Use this method to perform initialization tasks, such as:
// - Validating configuration
// - Initializing external connections (databases, caches, etc.)
// - Setting up monitoring and health checks
// - Performing pre-flight checks
// - Registering middleware or routes
OnStarting()
}
StartingEvent is called before the application starts. Implement this interface to perform initialization tasks.
type StoppedEvent ¶ added in v4.1.3
type StoppedEvent interface {
AppEvent
// OnStopped is called after the HTTP server has stopped accepting new requests.
// Use this method to perform cleanup tasks, such as:
// - Closing database connections
// - Stopping background workers or schedulers
// - Releasing resources
// Args:
// - ctx: The context for the shutdown process, which can be used to perform graceful shutdown operations.
OnStopped(ctx context.Context)
}
StoppedEvent is called after the HTTP server has stopped. Implement this interface to perform cleanup tasks.