circuitbreaker

package module
v0.0.0-...-d83bd77 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCircuitOpen      = errors.New("circuit breaker is open")
	ErrCircuitExhausted = errors.New("circuit breaker is exhausted")
)

Functions

This section is empty.

Types

type CircuitBreakerMiddleware

type CircuitBreakerMiddleware struct {
	// contains filtered or unexported fields
}

CircuitBreakerMiddleware implements the circuit breaker pattern to prevent cascading failures.

func New

func New(maxRequests uint32, interval, timeout time.Duration) *CircuitBreakerMiddleware

New creates a new CircuitBreakerMiddleware instance.

func (*CircuitBreakerMiddleware) Process

func (m *CircuitBreakerMiddleware) Process(ctx context.Context, httpClient *http.Client, req *http.Request, next middleware.NextFunc) (*http.Response, error)

Process applies the circuit breaker before passing the request to the next middleware.

func (*CircuitBreakerMiddleware) SetLogger

func (m *CircuitBreakerMiddleware) SetLogger(l logger.Logger)

SetLogger sets the logger for the middleware.

Jump to

Keyboard shortcuts

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