circuitbreaker

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultReadyToTrip

func DefaultReadyToTrip(
	requestThreshold uint32,
	consecutiveFailures uint32,
	failureRate float64,
) func(counts gobreaker.Counts) bool

DefaultReadyToTrip default function for circuit breaker

func NewCircuitBreakerClient

func NewCircuitBreakerClient(options ...Options) httpclient.ClientDoer

NewCircuitBreakerClient function to instantiate http client.

Types

type CounterErrorSkipperFunc

type CounterErrorSkipperFunc func(err error) bool

CounterErrorSkipperFunc function skipper circuit breaker counter return true to skip

func (CounterErrorSkipperFunc) Apply

func (c CounterErrorSkipperFunc) Apply(client *circuitBreakerClient)

Apply implements Options interface

type OnStateChangeFunc

type OnStateChangeFunc func(name string, from gobreaker.State, to gobreaker.State)

OnStateChangeFunc on state change hook

func (OnStateChangeFunc) Apply

func (o OnStateChangeFunc) Apply(client *circuitBreakerClient)

Apply implements Options interface

type Options

type Options interface {
	Apply(*circuitBreakerClient)
}

Options interface to extend circuit breaker client

func WithCounterErrorSkipper

func WithCounterErrorSkipper(skipperFunc func(err error) bool) Options

WithCounterErrorSkipper function to bring counter error skipper to circuit breaker

func WithHTTPClient

func WithHTTPClient(client *http.Client) Options

WithHTTPClient function to override http client doer

func WithInterval

func WithInterval(interval time.Duration) Options

WithInterval function to override circuit breaker interval

func WithMaxRequests

func WithMaxRequests(maxRequests uint32) Options

WithMaxRequests function to override circuit breaker max requests

func WithOnStateChangeFunc

func WithOnStateChangeFunc(hookFn func(name string, from gobreaker.State, to gobreaker.State)) Options

WithOnStateChangeFunc function to run hook on state change

func WithReadyToTripFunc

func WithReadyToTripFunc(hookFn func(counts gobreaker.Counts) bool) Options

WithReadyToTripFunc function to run hook on state change

func WithTimeout

func WithTimeout(timeout time.Duration) Options

WithTimeout function to override http client timeout

type ReadyToTripFunc

type ReadyToTripFunc func(counts gobreaker.Counts) bool

ReadyToTripFunc on ready to trip

func (ReadyToTripFunc) Apply

func (o ReadyToTripFunc) Apply(client *circuitBreakerClient)

Apply implements Options interface

Jump to

Keyboard shortcuts

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