heimdall: github.com/gojektech/heimdall Index | Files | Directories

package heimdall

import "github.com/gojektech/heimdall"

Index

Package Files

backoff.go client.go plugin.go retry.go

type Backoff Uses

type Backoff interface {
    Next(retry int) time.Duration
}

Backoff interface defines contract for backoff strategies

func NewConstantBackoff Uses

func NewConstantBackoff(backoffInterval, maximumJitterInterval time.Duration) Backoff

NewConstantBackoff returns an instance of ConstantBackoff The maximum jitter interval must be more than 1*time.Millisecond

func NewExponentialBackoff Uses

func NewExponentialBackoff(initialTimeout, maxTimeout time.Duration, exponentFactor float64, maximumJitterInterval time.Duration) Backoff

NewExponentialBackoff returns an instance of ExponentialBackoff The maximum jitter interval must be more than 1*time.Millisecond

type Client Uses

type Client interface {
    Get(url string, headers http.Header) (*http.Response, error)
    Post(url string, body io.Reader, headers http.Header) (*http.Response, error)
    Put(url string, body io.Reader, headers http.Header) (*http.Response, error)
    Patch(url string, body io.Reader, headers http.Header) (*http.Response, error)
    Delete(url string, headers http.Header) (*http.Response, error)
    Do(req *http.Request) (*http.Response, error)
    AddPlugin(p Plugin)
}

Client Is a generic HTTP client interface

type Doer Uses

type Doer interface {
    Do(*http.Request) (*http.Response, error)
}

Doer interface has the method required to use a type as custom http client. The net/*http.Client type satisfies this interface.

type Plugin Uses

type Plugin interface {
    OnRequestStart(*http.Request)
    OnRequestEnd(*http.Request, *http.Response)
    OnError(*http.Request, error)
}

Plugin defines the interface that a Heimdall plugin must have plugins can be added to a Heimdall client using the `AddPlugin` method

type Retriable Uses

type Retriable interface {
    NextInterval(retry int) time.Duration
}

Retriable defines contract for retriers to implement

func NewNoRetrier Uses

func NewNoRetrier() Retriable

NewNoRetrier returns a null object for retriable

func NewRetrier Uses

func NewRetrier(backoff Backoff) Retriable

NewRetrier returns retrier with some backoff strategy

func NewRetrierFunc Uses

func NewRetrierFunc(f RetriableFunc) Retriable

NewRetrierFunc returns a retrier with a retry function defined

type RetriableFunc Uses

type RetriableFunc func(retry int) time.Duration

RetriableFunc is an adapter to allow the use of ordinary functions as a Retriable

func (RetriableFunc) NextInterval Uses

func (f RetriableFunc) NextInterval(retry int) time.Duration

NextInterval calls f(retry)

Directories

PathSynopsis
examples
httpclient
hystrix
plugins

Package heimdall imports 5 packages (graph) and is imported by 14 packages. Updated 2020-02-24. Refresh now. Tools for package owners.