
infra
Package infra exposes the proxy-package backend infrastructure (backend map, usage tracker, drain checker, metrics, admission, per-op timeouts) as an importable type so subpackages can share it without an import cycle back to the root proxy package.
Index
- type Config
- type Core
- func New(cfg *Config) *Core
- func (c *Core) Acct() *accounting.Recorder
- func (c *Core) AcquireAdmission(ctx context.Context) bool
- func (c *Core) AdmissionSem() chan struct{}
- func (c *Core) BackendOrder() []string
- func (c *Core) Backends() map[string]backend.ObjectBackend
- func (c *Core) ClassifyWriteError(span trace.Span, operation string, err error) error
- func (c *Core) DeleteWithTimeout(ctx context.Context, be backend.ObjectBackend, key string) error
- func (c *Core) EligibleForWrite(apiCalls, egress, ingress int64) []string
- func (c *Core) ExcludeDraining(eligible []string) []string
- func (c *Core) ExcludeUnhealthy(eligible []string) []string
- func (c *Core) GetBackend(name string) (backend.ObjectBackend, error)
- func (c *Core) IsDraining(name string) bool
- func (c *Core) Log() *slog.Logger
- func (c *Core) MaxObjectSize(name string) int64
- func (c *Core) MetricsCollector() *metrics.Collector
- func (c *Core) RecordOperation(operation, backend string, start time.Time, err error)
- func (c *Core) ReleaseAdmission()
- func (c *Core) RoutingStrategy() config.RoutingStrategy
- func (c *Core) SetDrainChecker(d DrainChecker)
- func (c *Core) SetMetricsCollector(m *metrics.Collector)
- func (c *Core) StreamCopy(ctx context.Context, src, dst backend.ObjectBackend, key string) error
- func (c *Core) UpdateQuotaMetrics(ctx context.Context) error
- func (c *Core) Usage() *counter.UsageTracker
- func (c *Core) WithTimeout(ctx context.Context) (context.Context, context.CancelFunc)
- type DrainChecker
type Config
Config bundles every input *Core needs at construction. Exposed so callers (root proxy package, tests) can build a *Core directly.
type Core
Core composes the five capability services every proxy subpackage needs. Per-role store views live on the root-package BackendManager; *Core deliberately holds none.
func New
New constructs a *Core from cfg. The drain checker is wired post-construction via SetDrainChecker to break the BackendManager ↔ drain.Manager cycle. The accounting Recorder is built here so every consumer of *Core shares one instance that observes the same usage tracker and the (later-wired) metrics collector via the closure over c.RecordOperation.
func (*Core) Acct
Acct returns the shared accounting.Recorder. Consumers should call Acct().APICall / Egress / Ingress / Operation instead of reaching through Usage() and RecordOperation directly so the per-backend accounting rules stay centralised.
func (*Core) AcquireAdmission
AcquireAdmission blocks until a slot is available, or returns false if ctx is cancelled. Returns true immediately when no semaphore is wired.
func (*Core) AdmissionSem
AdmissionSem returns the underlying semaphore channel (nil if unwired). Callers that need the raw channel (split admission controllers) read this; the AcquireAdmission/ReleaseAdmission methods are preferred.
func (*Core) BackendOrder
BackendOrder returns the configured backend ordering (worker.Ops contract).
func (*Core) Backends
Backends returns the backend map (worker.Ops contract).
func (*Core) ClassifyWriteError
ClassifyWriteError translates store errors from write-path operations into S3-compatible errors and updates the tracing span.
func (*Core) DeleteWithTimeout
DeleteWithTimeout deletes an object from a backend using the configured backend timeout.
func (*Core) EligibleForWrite
EligibleForWrite returns backends that are not draining, not circuit-broken, and within usage limits / max-object-size for the given operation. Composed pipeline of registry filters + usage filter so each capability owns its half of the decision.
func (*Core) ExcludeDraining
ExcludeDraining filters out backends that are currently draining.
func (*Core) ExcludeUnhealthy
ExcludeUnhealthy filters out backends whose circuit breaker is open and not probe-eligible.
func (*Core) GetBackend
GetBackend returns the named backend, or an error if it doesn’t exist.
func (*Core) IsDraining
IsDraining returns true if the named backend is currently being drained. Returns false when no drain manager is wired.
func (*Core) Log
Log returns the component-scoped logger; falls back to slog.Default() when *Core was constructed without one.
func (*Core) MaxObjectSize
MaxObjectSize returns the per-backend max object size; 0 means unlimited.
func (*Core) MetricsCollector
MetricsCollector returns the wired metrics collector (nil if unset).
func (*Core) RecordOperation
RecordOperation delegates to the metrics collector.
func (*Core) ReleaseAdmission
ReleaseAdmission returns a slot to the admission semaphore.
func (*Core) RoutingStrategy
RoutingStrategy returns the configured routing strategy.
func (*Core) SetDrainChecker
SetDrainChecker installs the drain manager after Core has been constructed; mirrors the historic post-construction WireDrain call on BackendManager.
func (*Core) SetMetricsCollector
SetMetricsCollector installs the metrics collector after Core construction. The collector depends on the usage tracker which is owned by *Core, so the collector is built after *Core and wired back in.
func (*Core) StreamCopy
StreamCopy reads an object from src and writes it to dst with timeouts applied to each leg. Returns a *backend.CopyError tagged with the failing phase.
func (*Core) UpdateQuotaMetrics
UpdateQuotaMetrics refreshes Prometheus gauges from the metadata store.
func (*Core) Usage
Usage returns the usage tracker (worker.Ops contract).
func (*Core) WithTimeout
WithTimeout returns a context with the configured backend timeout applied.
type DrainChecker
DrainChecker reports whether a named backend is currently being drained. *Core consumes this so drain ownership can live in the drain subpackage while *Core filters write eligibility.
Generated by gomarkdoc