Documentation ¶
Index ¶
- func UnaryClientInterceptor(Name string, opts ...Option) grpc.UnaryClientInterceptor
- type Option
- func WithInterval(interval time.Duration) Option
- func WithMaxRequests(maxRequests uint32) Option
- func WithOnStateChange(onStateChange func(name string, from gobreaker.State, to gobreaker.State)) Option
- func WithReadyToTrip(readyToTrip func(counts gobreaker.Counts) bool) Option
- func WithTimeout(timeout time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(Name string, opts ...Option) grpc.UnaryClientInterceptor
Types ¶
type Option ¶
Option represents the gobreaker.Settings
func WithInterval ¶
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 ¶
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 ¶
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 ¶
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.