Documentation
¶
Overview ¶
Package di provides the dependency injection container for clean-wizard, built on samber/do v2. It centralizes all service registration and lifecycle management, replacing the former hand-wired dual-registry approach.
The container is created once at application startup, services are registered via RegisterAllServices, and the returned cleanup function ensures graceful shutdown of all services implementing do.ShutdownerWithError.
Index ¶
- Variables
- func CleanerRegistry(i do.Injector) (*cleaner.Registry, error)
- func Config(i do.Injector) (*domain.Config, error)
- func OverrideRegistry(injector do.Injector, replacement *cleaner.Registry)
- func OverrideSettings(injector do.Injector, settings RunSettings)
- func RegisterAllServices(injector do.Injector, cfg *domain.Config, settings RunSettings) error
- type Container
- type RunSettings
Constants ¶
This section is empty.
Variables ¶
var CleanerPackage = do.Package(
registerCleanerRegistry,
)
CleanerPackage groups all cleaner-related provider registrations. Using do.Package keeps the registration organized and composable, matching BuildFlow's InfrastructurePackage / ApplicationPackage pattern.
Functions ¶
func CleanerRegistry ¶
CleanerRegistry resolves the cleaner registry from the DI container. The registry is lazily created on first invocation with the registered RunSettings.
func OverrideRegistry ¶
OverrideRegistry replaces the cleaner registry in the DI container with a test double. This enables tests to inject mock or pre-configured registries without modifying the production registration logic.
func OverrideSettings ¶
func OverrideSettings(injector do.Injector, settings RunSettings)
OverrideSettings replaces the run settings in the DI container with test values.
func RegisterAllServices ¶
RegisterAllServices wires every application service into the DI container. It registers the already-loaded config and run settings as eager values, then invokes the provider packages for lazy service creation.
This is the single entry point for service registration, mirroring BuildFlow's di.RegisterAllServices pattern.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container wraps a samber/do injector with lifecycle management. It is the single entry point for resolving any service in the application.
func New ¶
func New() (*Container, func())
New creates a fresh Container with an empty injector. The returned cleanup function must be deferred to ensure all services implementing do.ShutdownerWithError are gracefully stopped.
func (*Container) Injector ¶
Injector exposes the underlying samber/do injector for direct use with do.Provide, do.Invoke, etc.
func (*Container) Shutdown ¶
func (c *Container) Shutdown() *do.ShutdownReport
Shutdown gracefully shuts down all registered services.
type RunSettings ¶
RunSettings holds the runtime flags parsed from the CLI. These are registered as an eager value in the DI container so that all cleaner providers can resolve them lazily.