grpcsonybreaker

package
v0.0.0-...-32e62f0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnaryClientInterceptor

func UnaryClientInterceptor(Name string, opts ...Option) grpc.UnaryClientInterceptor

Types

type Option

type Option func(*gobreaker.Settings)

Option represents the gobreaker.Settings

func WithInterval

func WithInterval(interval time.Duration) Option

WithInterval sets Interval. Interval is the cyclic period of the closed state for the CircuitBreaker to clear the internal Counts. If Interval is 0, the CircuitBreaker doesn't clear internal Counts during the closed state.

func WithMaxRequests

func WithMaxRequests(maxRequests uint32) Option

WithMaxRequests sets MaxRequests. MaxRequests is the maximum number of requests allowed to pass through when the CircuitBreaker is half-open. If MaxRequests is 0, the CircuitBreaker allows only 1 request.

func WithOnStateChange

func WithOnStateChange(onStateChange func(name string, from gobreaker.State, to gobreaker.State)) Option

WithOnStateChange sets OnStateChange. OnStateChange is called whenever the state of the CircuitBreaker changes.

func WithReadyToTrip

func WithReadyToTrip(readyToTrip func(counts gobreaker.Counts) bool) Option

WithReadyToTrip set ReadyToTrip. ReadyToTrip is called with a copy of Counts whenever a request fails in the closed state. If ReadyToTrip returns true, the CircuitBreaker will be placed into the open state. If ReadyToTrip is nil, default ReadyToTrip is used. Default ReadyToTrip returns true when the number of consecutive failures is more than 5.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets Timeout. Timeout is the period of the open state, after which the state of the CircuitBreaker becomes half-open. If Timeout is 0, the timeout value of the CircuitBreaker is set to 60 seconds.

Jump to

Keyboard shortcuts

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