circuitbreakingcfg

package
v9.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureCircuitBreaker

func EnsureCircuitBreaker(breaker circuitbreaking.CircuitBreaker) circuitbreaking.CircuitBreaker

EnsureCircuitBreaker ensures a valid CircuitBreaker is made available.

func NewCircuitBreaker

func NewCircuitBreaker(ctx context.Context, cfg *Config, opts ...Option) (circuitbreaking.CircuitBreaker, error)

NewCircuitBreaker provides a CircuitBreaker from config.

func RegisterCircuitBreaker

func RegisterCircuitBreaker(i do.Injector)

RegisterCircuitBreaker registers a CircuitBreaker with the injector.

Types

type Config

type Config struct {
	Name                   string  `env:"NAME"                     json:"name,omitempty"                                     yaml:"name,omitempty"`
	ErrorRate              float64 `` /* 135-byte string literal not displayed */
	MinimumSampleThreshold uint64  `` /* 146-byte string literal not displayed */
}

func (*Config) EnsureDefaults

func (cfg *Config) EnsureDefaults()

func (*Config) NewCircuitBreaker

func (cfg *Config) NewCircuitBreaker(ctx context.Context, opts ...Option) (circuitbreaking.CircuitBreaker, error)

NewCircuitBreaker provides a CircuitBreaker.

func (*Config) ValidateWithContext

func (cfg *Config) ValidateWithContext(ctx context.Context) error

type Option

type Option func(*options)

Option customizes how a CircuitBreaker is provided.

The observability dependencies are options rather than parameters because both are genuinely optional: an absent logger logs nowhere and an absent metrics provider records nothing. Requiring them positionally made a caller that wanted neither name both anyway, usually as noops.

There is no tracer provider here. A circuit breaker's decisions are counters and log lines, not spans — it has nothing to trace.

func WithLogger

func WithLogger(logger logging.Logger) Option

WithLogger attaches a logger. An absent logger logs nowhere.

func WithMetricAttributes

func WithMetricAttributes(attrs ...attribute.KeyValue) Option

WithMetricAttributes attaches a fixed set of attributes to every metric the circuit breaker emits. It is used to distinguish breakers that share counter names (for example, tagging a per-key breaker with its partition).

func WithMetricsProvider

func WithMetricsProvider(metricsProvider metrics.Provider) Option

WithMetricsProvider attaches a metrics provider for the breaker's tripped, failed, and reset counters. An absent provider records nothing.

func WithPillars

func WithPillars(p *observability.Pillars) Option

WithPillars attaches a logger and metrics provider in one go, for the common case where a caller has already built them together. A nil Pillars attaches nothing. The pillars' tracer provider is ignored — see Option.

It is applied in order with the individual options, so a caller can hand over its pillars and then override one of them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址