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 ¶
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.
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 ¶
WithLogger attaches a logger. An absent logger logs nowhere.
func WithMetricAttributes ¶
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 ¶
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.