transport

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConnectTimeout      = 2 * time.Second
	DefaultKeepAliveDuration   = 5 * time.Minute
	DefaultMaxIdleConnsPerHost = 64
	DefaultTLSHandshakeTimeout = 2 * time.Second
)
View Source
const (
	DefaultResetPeriod = 5 * time.Minute
)

Variables

This section is empty.

Functions

func URLDecode

func URLDecode(data []byte, itf interface{}) error

func URLEncode

func URLEncode(itf interface{}) string

Types

type Host

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

type Outcome

type Outcome int
const (
	DefaultReadTimeout  = 5 * time.Second
	DefaultWriteTimeout = 30 * time.Second

	Success Outcome = iota
	Failure
	Retry
)

type Requester

type Requester interface {
	Request(req *http.Request) (*http.Response, error)
}

type RetryStrategy

type RetryStrategy struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*RetryStrategy) Decide

func (s *RetryStrategy) Decide(h Host, code int, err error) Outcome

func (*RetryStrategy) GetTryableHosts

func (s *RetryStrategy) GetTryableHosts(k call.Kind) (hosts []Host)

type StatefulHost

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

func NewStatefulHost

func NewStatefulHost(host string, accept func(k call.Kind) bool) *StatefulHost

func Shuffle

func Shuffle(hosts []*StatefulHost) []*StatefulHost

type Transport

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

func New

func New(
	hosts []*StatefulHost,
	requester Requester,
	appID string,
	apiKey string,
	readTimeout time.Duration,
	writeTimeout time.Duration,
	defaultHeaders map[string]string,
	extraUserAgent string,
	compression compression.Compression,
) *Transport

func (*Transport) Request

func (t *Transport) Request(
	res interface{},
	method string,
	path string,
	body interface{},
	k call.Kind,
	opts ...interface{},
) error

Jump to

Keyboard shortcuts

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