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

package heimdall

import "github.com/gojektech/heimdall"


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

func NewExponentialBackoff Uses

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

NewExponentialBackoff returns an instance of ExponentialBackoff

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 {
    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)



Package heimdall imports 5 packages (graph) and is imported by 6 packages. Updated 2020-06-08. Refresh now. Tools for package owners.