resilience

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BreakerOptions

type BreakerOptions struct {
	ErrorThreshold int
	Timeout        time.Duration
}

BreakerOptions configures the Circuit Breaker behavior.

type CircuitBreakerStepWrapper

type CircuitBreakerStepWrapper[T any] struct {
	BaseStep     pipeline.Step[T]
	FallbackStep pipeline.Step[T]
	// contains filtered or unexported fields
}

CircuitBreakerStepWrapper wraps a generation/retrieval step to provide fast failure and elegant fallback when the primary service degrades.

func WithCircuitBreakerAndFallback

func WithCircuitBreakerAndFallback[T any](base pipeline.Step[T], fallback pipeline.Step[T], opts BreakerOptions) *CircuitBreakerStepWrapper[T]

WithCircuitBreakerAndFallback creates a new circuit breaker wrapper for any step type.

func (*CircuitBreakerStepWrapper[T]) Execute

func (w *CircuitBreakerStepWrapper[T]) Execute(ctx context.Context, state T) error

func (*CircuitBreakerStepWrapper[T]) Name

func (w *CircuitBreakerStepWrapper[T]) Name() string

type RateLimiterStepWrapper

type RateLimiterStepWrapper[T any] struct {
	BaseStep pipeline.Step[T]
	// contains filtered or unexported fields
}

RateLimiterStepWrapper wraps any pipeline Step with a Token Bucket rate limiter.

func WithRateLimiter

func WithRateLimiter[T any](base pipeline.Step[T], limit rate.Limit, burst int) *RateLimiterStepWrapper[T]

WithRateLimiter creates a new rate limiter wrapper for any step type.

func (*RateLimiterStepWrapper[T]) Execute

func (w *RateLimiterStepWrapper[T]) Execute(ctx context.Context, state T) error

func (*RateLimiterStepWrapper[T]) Name

func (w *RateLimiterStepWrapper[T]) Name() string

Jump to

Keyboard shortcuts

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