services

package
v0.0.0-...-bcded96 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBackoffConfig = BackoffConfig{
	InitialInterval:     100 * time.Millisecond,
	MaxInterval:         1500 * time.Millisecond,
	MaxElapsedTime:      10 * time.Second,
	RandomizationFactor: backoff.DefaultRandomizationFactor,
	Multiplier:          backoff.DefaultMultiplier,
}

DefaultBackoffConfig ...

View Source
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 Breaker

type Breaker struct {
	CB *breaker.Breaker
}

Breaker ...

func NewBreaker

func NewBreaker(config BreakerConfig) Breaker

NewBreaker ...

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

type ConstantRetryPolicy struct {
	Interval time.Duration
	Max      int
}

ConstantRetryPolicy ...

func (*ConstantRetryPolicy) Backoffs

func (c *ConstantRetryPolicy) Backoffs() []time.Duration

Backoffs ...

func (*ConstantRetryPolicy) Retry

func (c *ConstantRetryPolicy) Retry(req *http.Request) bool

Retry ...

type ExponentialRetryPolicy

type ExponentialRetryPolicy struct {
	// contains filtered or unexported fields
}

ExponentialRetryPolicy ...

func (*ExponentialRetryPolicy) Backoffs

func (e *ExponentialRetryPolicy) Backoffs() []time.Duration

Backoffs ...

func (*ExponentialRetryPolicy) Retry

func (e *ExponentialRetryPolicy) Retry(req *http.Request) bool

Retry ...

type NoRetryPolicy

type NoRetryPolicy struct{}

NoRetryPolicy ...

func (*NoRetryPolicy) Backoffs

func (n *NoRetryPolicy) Backoffs() []time.Duration

Backoffs ...

func (*NoRetryPolicy) Retry

func (n *NoRetryPolicy) Retry(req *http.Request) bool

Retry ...

type RetryPolicy

type RetryPolicy interface {
	Backoffs() []time.Duration
	Retry(*http.Request) bool
}

RetryPolicy ...

func NewConstantRetryPolicy

func NewConstantRetryPolicy(interval time.Duration, maxRetries int) RetryPolicy

NewConstantRetryPolicy ...

func NewExponentialRetryPolicy

func NewExponentialRetryPolicy(config BackoffConfig) RetryPolicy

NewExponentialRetryPolicy ...

func NewNoRetryPolicy

func NewNoRetryPolicy() RetryPolicy

NewNoRetryPolicy ...

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

type SingleRetryPolicy struct {
	Interval time.Duration
}

SingleRetryPolicy ...

func (*SingleRetryPolicy) Backoffs

func (s *SingleRetryPolicy) Backoffs() []time.Duration

Backoffs ...

func (*SingleRetryPolicy) Retry

func (s *SingleRetryPolicy) Retry(req *http.Request) bool

Retry ...

type Status

type Status interface {
	Get(string) bool
	Set(string, bool) error
}

Status ...

func NewStatus

func NewStatus() Status

NewStatus ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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