transport

package
v3.17.1-0...-72ab6c1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 21 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 DefaultHTTPClient

func DefaultHTTPClient() *http.Client

DefaultHTTPClient exposes the default *http.Client used by the different Client instances of the Algolia API client.

Most users should not need to access this http.Client.

This helper is only useful for users who wish to keep the default behavior of the Algolia API client (by wrapping it in a user-defined instance of transport.Requester) but would like to wrap it into a middleware layer or pass it to an HTTP interceptor.

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 {
	Scheme string
	// 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