Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultBackoffConfig = BackoffConfig{ InitialInterval: 100 * time.Millisecond, MaxInterval: 1500 * time.Millisecond, MaxElapsedTime: 10 * time.Second, RandomizationFactor: backoff.DefaultRandomizationFactor, Multiplier: backoff.DefaultMultiplier, }
DefaultBackoffConfig ...
var DefaultBreakerConfig = BreakerConfig{ ErrorThreshold: 3, SuccessThreshold: 1, Timeout: 10 * time.Second, }
DefaultBreakerConfig ...
Functions ¶
This section is empty.
Types ¶
type BackoffConfig ¶
type BackoffConfig struct { InitialInterval time.Duration RandomizationFactor float64 Multiplier float64 MaxInterval time.Duration MaxElapsedTime time.Duration }
BackoffConfig ...
type BreakerConfig ¶
type BreakerConfig struct { // NOTE: should set ErrorThreshold to the length of the backoffs slice in the RetryPoliicy (!!) ErrorThreshold int // NOTE: SuccessThreshold should almost always be 1; this determines the number of times a CB will retry after breaking SuccessThreshold int Timeout time.Duration }
BreakerConfig ...
type ConstantRetryPolicy ¶
ConstantRetryPolicy ...
func (*ConstantRetryPolicy) Backoffs ¶
func (c *ConstantRetryPolicy) Backoffs() []time.Duration
Backoffs ...
type ExponentialRetryPolicy ¶
type ExponentialRetryPolicy struct {
// contains filtered or unexported fields
}
ExponentialRetryPolicy ...
func (*ExponentialRetryPolicy) Backoffs ¶
func (e *ExponentialRetryPolicy) Backoffs() []time.Duration
Backoffs ...
type RetryPolicy ¶
RetryPolicy ...
func NewConstantRetryPolicy ¶
func NewConstantRetryPolicy(interval time.Duration, maxRetries int) RetryPolicy
NewConstantRetryPolicy ...
func NewExponentialRetryPolicy ¶
func NewExponentialRetryPolicy(config BackoffConfig) RetryPolicy
NewExponentialRetryPolicy ...
func NewSingleRetryPolicy ¶
func NewSingleRetryPolicy(interval time.Duration) RetryPolicy
NewSingleRetryPolicy ...
type Service ¶
type Service interface { Do(*http.Request) (*http.Response, error) SetRetryPolicy(RetryPolicy) SetCircuitBreaker(Breaker) SetTransport(*http.Transport) GetStatus() bool SetStatus(bool) }
Service is a standard utility interface that can be embedded in any service interface ... NOTE: if an API endpoint requires a different retry-policy or a different circuit-breaker configuration, etc. a new client will need to be created inside the handler and the new policies/configs can be specified via these methods. This will alter the behavior of the service Client's methods.
type SingleRetryPolicy ¶
SingleRetryPolicy ...
func (*SingleRetryPolicy) Backoffs ¶
func (s *SingleRetryPolicy) Backoffs() []time.Duration
Backoffs ...