Documentation
¶
Overview ¶
Package app provides the core application framework for the MDW API Platform. It handles application lifecycle, module registration, and service orchestration.
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
}
App represents the main application instance. It manages the lifecycle and coordination of all application components.
func New ¶
New creates a new application instance with all necessary dependencies. It initializes configuration, logging, database, and HTTP server components.
func (*App) RegisterModule ¶
RegisterModule registers a new module with the application. It adds the module to the registry for initialization and route registration.
type Module ¶
type Module interface {
Name() string
Init(deps *ModuleDeps) error
RegisterRoutes(hr *server.HandlerRegistry, e *echo.Echo)
RegisterMessaging(registry *messaging.Registry)
Shutdown() error
}
Module defines the interface that all application modules must implement. It provides hooks for initialization, route registration, messaging setup, and cleanup.
type ModuleDeps ¶
type ModuleDeps struct {
DB database.Interface
Logger logger.Logger
Messaging messaging.Client
Config *config.Config
}
ModuleDeps contains the dependencies that are injected into each module. It provides access to core services like database, logging, and messaging.
type ModuleRegistry ¶
type ModuleRegistry struct {
// contains filtered or unexported fields
}
ModuleRegistry manages the registration and lifecycle of application modules. It handles module initialization, route registration, messaging setup, and shutdown.
func NewModuleRegistry ¶
func NewModuleRegistry(deps *ModuleDeps) *ModuleRegistry
NewModuleRegistry creates a new module registry with the given dependencies. It initializes an empty registry ready to accept module registrations.
func (*ModuleRegistry) Register ¶
func (r *ModuleRegistry) Register(module Module) error
Register adds a module to the registry and initializes it. It calls the module's Init method with the injected dependencies.
func (*ModuleRegistry) RegisterMessaging ¶
func (r *ModuleRegistry) RegisterMessaging() error
RegisterMessaging calls RegisterMessaging on all registered modules. It should be called after all modules have been registered but before starting the server.
func (*ModuleRegistry) RegisterRoutes ¶
func (r *ModuleRegistry) RegisterRoutes(e *echo.Echo)
RegisterRoutes calls RegisterRoutes on all registered modules. It should be called after all modules have been registered.
func (*ModuleRegistry) Shutdown ¶
func (r *ModuleRegistry) Shutdown() error
Shutdown gracefully shuts down all registered modules. It calls each module's Shutdown method and logs any errors.