Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CircuteBreakerForJust429 = gobreaker.NewCircuitBreaker(gobreaker.Settings{ Name: "circuteBreakerForJust429", MaxRequests: 0, Interval: 10 * time.Second, Timeout: 20 * time.Second, ReadyToTrip: func(counts gobreaker.Counts) bool { return counts.ConsecutiveFailures > 0 }, IsSuccessful: func(err error) bool { return err.Error() != "429" }, })
Functions ¶
This section is empty.
Types ¶
type BackoffStrategyExpnential ¶
type BackoffStrategyExpnential struct {
// contains filtered or unexported fields
}
func NewRetryInterceptor_BackoffStrategyLinier ¶
func NewRetryInterceptor_BackoffStrategyLinier(baseDuration time.Duration) BackoffStrategyExpnential
func NewRetryInterceptor_ExponentialBackoff ¶
func NewRetryInterceptor_ExponentialBackoff(baseDuration, maxBackoff time.Duration) BackoffStrategyExpnential
func (BackoffStrategyExpnential) TimeToWait ¶
func (b BackoffStrategyExpnential) TimeToWait(iteration int) time.Duration
type BackoffStrategyLinier ¶
type BackoffStrategyLinier struct {
// contains filtered or unexported fields
}
func (BackoffStrategyLinier) TimeToWait ¶
func (b BackoffStrategyLinier) TimeToWait(iteration int) time.Duration
type BackoffTimer ¶
type CircuitBreakerInterceptor ¶
type CircuitBreakerInterceptor struct {
// contains filtered or unexported fields
}
func NewCircuitBreakerInterceptor ¶
func NewCircuitBreakerInterceptor(cb *gobreaker.CircuitBreaker, abortOnFailure bool) *CircuitBreakerInterceptor
NewCircuitBreakerInterceptor creates a new circuit breaker interceptor faced status codes (including 2xx) are passed as simple string to ReadyToTrip function.
func (*CircuitBreakerInterceptor) AfterResponse ¶
func (c *CircuitBreakerInterceptor) AfterResponse(data InterceptorData) InterceptorData
AfterResponse records failures in the circuit breaker
func (*CircuitBreakerInterceptor) BeforeRequest ¶
func (c *CircuitBreakerInterceptor) BeforeRequest(data InterceptorData) InterceptorData
BeforeRequest checks if the circuit breaker is open
type ClientHandler ¶
type ClientInterceptor ¶
type ClientInterceptor interface {
// BeforeRequest is called before executing an HTTP request
// It can modify the request or perform pre-request actions
//
// NOTE: moidfiying InterceptorData.Response at this step will prevent calling AfterResponse
// and directly returns this response as response of server
BeforeRequest(InterceptorData) InterceptorData
// AfterResponse is called after receiving an HTTP response
// It can modify the response or perform post-response actions
AfterResponse(InterceptorData) InterceptorData
}
type InterceptorData ¶
type RetryDecider ¶
type RetryDecider interface {
// ShouldRetry determines whether a failed HTTP request should be retried.
// It receives the HTTP response (if any), the error (if any), and retry metadata.
// Returns:
// - bool: true if the request should be retried, false otherwise
// - error: non-nil if an error occurred during the decision process. returning error stops the whole interceptorsChain.
ShouldRetry(*http.Response, error, RetryInternalData) (bool, error)
}
type RetryDeciderAll ¶
type RetryDeciderAll struct {
// contains filtered or unexported fields
}
func NewRetryInterceptor_RetryDeciderAll ¶
func NewRetryInterceptor_RetryDeciderAll(maxRetries int) RetryDeciderAll
func (RetryDeciderAll) ShouldRetry ¶
func (r RetryDeciderAll) ShouldRetry(response *http.Response, err error, retryData RetryInternalData) (bool, error)
type RetryInterceptor ¶
type RetryInterceptor struct {
// contains filtered or unexported fields
}
func NewRetryInterceptor ¶
func NewRetryInterceptor(clientHandler ClientHandler, backoffStrategy BackoffTimer, retryDecider RetryDecider) *RetryInterceptor
func (*RetryInterceptor) AfterResponse ¶
func (e *RetryInterceptor) AfterResponse(data InterceptorData) InterceptorData
func (*RetryInterceptor) BeforeRequest ¶
func (e *RetryInterceptor) BeforeRequest(data InterceptorData) InterceptorData
type RetryInternalData ¶
type RetryInternalData struct {
RetryCount int
}
Click to show internal directories.
Click to hide internal directories.