
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(deps InjectorDeps) 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 ProvideBackendRuntime(i do.Injector) (*infra.BackendRuntime, 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 ProvideFlightRecorderService(i do.Injector) (*debug.FlightRecorderService, error)
- func ProvideInstanceID(_ do.Injector) (instanceid.ID, error)
- func ProvideIntegrityConfig(_ do.Injector) (*syncutil.AtomicConfig[config.IntegrityConfig], 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 ProvideMultipartManager(i do.Injector) (*multipart.Manager, 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 ProvideWriteCoordinator(i do.Injector) (*writepath.Coordinator, error)
- func WireAuditMetrics()
- func WireManager(inj do.Injector) error
- type BackendsResult
- type InjectorDeps
- 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 the DI container and registers every provider the service needs. The body is intentionally a flat sequence of per-domain registration calls so a contributor can see the full dependency graph in one screen; each helper below owns the providers for its domain.
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
func ProvideBackendRuntime
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. ProvideBackendRuntime builds the backend runtime: the fleet registry, usage tracker, admission semaphore, timeout policy, error classification, and metrics collector. Constructing it here (rather than inside NewBackendManager) makes the runtime a first-class, independently-resolvable dependency that workers, drain, and the manager all share, instead of a promoted embed only reachable through the manager.
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. It resolves the backend runtime and store directly rather than through the manager so the drain manager (which takes this worker’s ProcessCleanupQueue hook) can be built before the manager.
func ProvideDatabaseBreaker
ProvideDatabaseBreaker constructs the shared *breaker.CircuitBreaker every driver-level SQL statement forwards calls through.
func ProvideDrainManager
ProvideDrainManager constructs the drain manager from the backend runtime (fleet/copy/delete primitives), the write coordinator (its mover), the wide MetadataStore for the object/quota/lifecycle role surfaces, the multipart manager’s abort hook, and the cleanup worker’s queue flush. None of these is the BackendManager, so drain builds before the manager and is injected into it.
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 ProvideFlightRecorderService
ProvideFlightRecorderService constructs the always-on runtime/trace FlightRecorder wrapper that the admin trace-snapshot endpoint streams from. Only registered when cfg.Debug.FlightRecorder.Enabled is true, so resolution failure means the operator did not opt in.
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 ProvideIntegrityConfig
ProvideIntegrityConfig provides the atomic integrity config shared by the multipart manager and the object manager so a SIGHUP flips both write paths’ hashing behavior in one swap.
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 ProvideMultipartManager
ProvideMultipartManager builds the multipart upload lifecycle manager. Built outside the BackendManager so the drain manager can take its AbortMultipartUploadsOnBackend hook directly.
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. The provider is registered in NewInjector only when the pending pattern is enabled, so reaching this function implies the feature is on. Any nil dependency at this point is a wiring bug, not a “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 ProvideWriteCoordinator
ProvideWriteCoordinator builds the write coordinator: the shared delete/move/orphan-cleanup primitive the manager, multipart manager, object manager, and drain manager all route writes through.
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 points the runtime’s eligibility filter at the drain manager. 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 InjectorDeps
InjectorDeps groups the values NewInjector seeds the container with.
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