
di
Package di is the single wiring point for the orchestrator. It uses samber/do/v2 to register every store role, backend, worker, and transport handler as a lazy provider; consumers resolve their dependencies through the injector at the moment they need them.
Index
- func IsRegistered[T any](inj do.Injector) bool
- func NewInjector(cfg *config.Config, mode string, logLevel *slog.LevelVar, logBuffer *telemetry.LogBuffer) do.Injector
- func NewLifecycleService(manager lifecycleOps, locker tickrunner.AdvisoryLocker) lifecycle.Runner
- func NewUsageFlushService(manager usageFlushOps, locker tickrunner.AdvisoryLocker) lifecycle.Runner
- func ProvideAdminHandler(i do.Injector) (*admin.Handler, error)
- func ProvideBackendManager(i do.Injector) (*proxy.BackendManager, error)
- func ProvideBreakerRegistry(i do.Injector) (*breaker.Registry, error)
- func ProvideBucketAuth(i do.Injector) (*auth.BucketRegistry, error)
- func ProvideCleanupWorker(i do.Injector) (*worker.CleanupWorker, error)
- func ProvideDatabaseBreaker(i do.Injector) (*breaker.CircuitBreaker, error)
- func ProvideDrainManager(i do.Injector) (*drain.Manager, error)
- func ProvideEncryptionAdmin(i do.Injector) (core.EncryptionAdmin, error)
- func ProvideEncryptionProvider(i do.Injector) (encryption.KeyProvider, error)
- func ProvideEncryptor(i do.Injector) (*encryption.Encryptor, error)
- func ProvideInstanceID(_ do.Injector) (instanceid.ID, error)
- func ProvideLifecycleAdmin(i do.Injector) (core.LifecycleAdmin, error)
- func ProvideLifecycleManager(i do.Injector) (*lifecycle.Manager, error)
- func ProvideLoginThrottle(_ do.Injector) (*httputil.LoginThrottle, error)
- func ProvideMetadataStore(i do.Injector) (core.MetadataStore, error)
- func ProvideMetricsDeps(i do.Injector) (metrics.Deps, error)
- func ProvideNotificationOutbox(i do.Injector) (core.NotificationOutbox, error)
- func ProvideNotifier(i do.Injector) (*notify.Notifier, error)
- func ProvideObjectCache(i do.Injector) (objcache.ObjectCache, error)
- func ProvideOverReplicationCleaner(i do.Injector) (*worker.OverReplicationCleaner, error)
- func ProvidePendingReaper(i do.Injector) (*worker.PendingReaper, error)
- func ProvideRateLimiter(i do.Injector) (*s3api.RateLimiter, error)
- func ProvideRebalancer(i do.Injector) (*worker.Rebalancer, error)
- func ProvideReconciler(i do.Injector) (*worker.Reconciler, error)
- func ProvideRedisCounterBackend(i do.Injector) (*counter.RedisCounterBackend, error)
- func ProvideReplicator(i do.Injector) (*worker.Replicator, error)
- func ProvideS3Server(i do.Injector) (*s3api.Server, error)
- func ProvideScrubber(i do.Injector) (*worker.Scrubber, error)
- func ProvideUIHandler(i do.Injector) (*ui.Handler, error)
- func WireAuditMetrics()
- func WireManager(inj do.Injector) error
- type BackendsResult
- type OptionalResult
- type Resolution
func IsRegistered
IsRegistered reports whether T has a provider registered in the injector or any ancestor scope. Cheap; does not invoke the constructor.
func NewInjector
NewInjector creates and configures the DI container. Required providers are always registered. Optional providers register only when their config section is enabled - do.Invoke returns an error for disabled services, which callers use to detect absence.
func NewLifecycleService
NewLifecycleService constructs the lifecycle-expiration background service. Lives in DI (rather than next to a worker) because the work surface is on *proxy.BackendManager itself (via the lifecycleOps consumer interface) - there is no dedicated worker type.
func NewUsageFlushService
NewUsageFlushService constructs the usage flush background service.
func ProvideAdminHandler
ProvideAdminHandler creates the admin API handler.
func ProvideBackendManager
ProvideBackendManager creates the central orchestration manager with the narrow per-role store interfaces supplied. Also installs a recovery listener on the DB breaker so the degraded-mode location cache is cleared the moment the DB transitions back to closed.
func ProvideBreakerRegistry
ProvideBreakerRegistry assembles the watchdog’s breaker registry from the database circuit breaker and the per-backend breakers produced during backend initialization. Centralizing membership here keeps the watchdog itself free of type-assertions and keeps DI as the single wiring point.
func ProvideBucketAuth
ProvideBucketAuth creates the credential-to-bucket registry.
func ProvideCleanupWorker
ProvideCleanupWorker constructs the cleanup-queue worker.
func ProvideDatabaseBreaker
ProvideDatabaseBreaker constructs the shared *breaker.CircuitBreaker every driver-level SQL statement forwards calls through.
func ProvideDrainManager
ProvideDrainManager constructs the drain manager. Depends on BackendManager (drain.Core seam), the cleanup worker (for the cleanup-queue flush before backend deletion), and the wide MetadataStore for the object/quota/lifecycle role surfaces. The returned manager is wired onto BackendManager by di.WireManager so the provider itself stays free of mutation side effects.
func ProvideEncryptionAdmin
ProvideEncryptionAdmin aliases the wide MetadataStore as its EncryptionAdmin role for the admin HTTP handler’s key rotation and encrypt/decrypt batch ops.
func ProvideEncryptionProvider
ProvideEncryptionProvider creates the key provider for admin key rotation operations. Only registered when encryption is enabled.
func ProvideEncryptor
ProvideEncryptor creates the envelope encryption engine.
func ProvideInstanceID
ProvideInstanceID resolves a stable per-process identifier used as the claimed_by stamp on cleanup_queue rows. The identifier is generated once at first invoke and reused everywhere the value is needed.
func ProvideLifecycleAdmin
ProvideLifecycleAdmin aliases the wide MetadataStore as its LifecycleAdmin role for boot/shutdown migrations, schema checks, and Close.
func ProvideLifecycleManager
ProvideLifecycleManager creates and registers all background services.
func ProvideLoginThrottle
ProvideLoginThrottle creates the per-IP login attempt throttle.
func ProvideMetadataStore
ProvideMetadataStore opens the configured driver, runs migrations, syncs quota limits, and returns the wide core.MetadataStore every consumer depends on. CB protection lives inside each driver’s DBTX/DB chokepoint, so this provider does no wrapping of its own.
func ProvideMetricsDeps
ProvideMetricsDeps aliases the wide MetadataStore as the metrics.Deps subset metrics.Collector uses to refresh Prometheus gauges.
func ProvideNotificationOutbox
ProvideNotificationOutbox aliases the wide MetadataStore as its NotificationOutbox role for the notifier worker.
func ProvideNotifier
ProvideNotifier creates the webhook notification system.
func ProvideObjectCache
ProvideObjectCache creates the in-memory LRU object data cache.
func ProvideOverReplicationCleaner
ProvideOverReplicationCleaner constructs the over-replication cleanup worker.
func ProvidePendingReaper
ProvidePendingReaper constructs the pending-reaper worker. This provider is registered in NewInjector ONLY when the pending pattern is enabled, so reaching this function implies the feature is on (#830). Any nil dependency at this point is a wiring bug, not an intentional “feature off” signal - it surfaces as an error so Optional[*worker.PendingReaper] reports Failed instead of conflating it with Disabled.
func ProvideRateLimiter
ProvideRateLimiter creates the per-IP rate limiter.
func ProvideRebalancer
ProvideRebalancer constructs the rebalancer worker.
func ProvideReconciler
ProvideReconciler constructs the bucket reconciler worker. Registered only in worker/all modes because reconciliation is a worker-side background task. Returns the reconciler so the lifecycle manager can register a service for it; the reconciler is also resolvable directly for the admin handler’s inspection endpoints.
func ProvideRedisCounterBackend
ProvideRedisCounterBackend creates the shared Redis counter backend.
func ProvideReplicator
ProvideReplicator constructs the replication worker.
func ProvideS3Server
ProvideS3Server creates the S3-compatible HTTP handler.
func ProvideScrubber
ProvideScrubber constructs the integrity-verification worker.
func ProvideUIHandler
ProvideUIHandler creates the web dashboard handler.
func WireAuditMetrics
WireAuditMetrics connects the audit event counter to Prometheus. Called from the main binary during startup, outside the injector.
func WireManager
WireManager resolves the BackendManager plus every required worker (as a smoke check that construction succeeded) and installs the drain manager onto the BackendManager. Returns the first error from resolving a required dependency; the optional PendingReaper Failed resolution is logged so a broken provider stays distinguishable from an intentionally absent one.
type BackendsResult
BackendsResult groups the outputs of backend initialization so multiple providers can resolve it without re-running construction.
func ProvideBackends
ProvideBackends initializes all configured storage backends, wrapping each with a per-backend circuit breaker when enabled.
type OptionalResult
OptionalResult carries the outcome of an Optional[T] lookup. Callers pick the field they care about: Value for the resolved instance, Resolution for the operational classification, Err for the failure detail when Resolution is Failed.
func Optional
Optional resolves T as an optional dependency. Inspects the injector’s registered service list first so a missing provider is distinguished from a constructor failure: a Disabled result means the feature was never wired in this run mode, while a Failed result means a provider was wired but its constructor (or a transitive dependency it tried to resolve) returned an error.
func (OptionalResult[T]) Applied
Applied reports whether the provider resolved cleanly.
func (OptionalResult[T]) Disabled
Disabled reports whether the underlying provider was not registered.
func (OptionalResult[T]) Failed
Failed reports whether the provider was registered but failed to construct (or one of its transitive dependencies failed).
type Resolution
Resolution classifies the outcome of an optional dependency lookup.
Generated by gomarkdoc