httpclient

package
v0.0.0-...-a49da23 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRetryMin is the default minimum retry time
	DefaultRetryMin = 1 * time.Second
	// DefaultRetryMax is the default maximum retry time
	DefaultRetryMax = 10 * time.Second
)
View Source
const GET = "GET"

GET is used for HTTP GET calls

View Source
const POST = "POST"

POST is used for HTTP POST calls

View Source
const PUT = "PUT"

PUT is used for HTTP PUT calls

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientHost

type ClientHost struct {
	APIKey  string `json:"-"` // never marshal this
	HostURL string

	// NoProxy will be set to true when the proxy setting for the trace API endpoint
	// needs to be ignored (e.g. it is part of the "no_proxy" list in the yaml settings).
	NoProxy           bool
	ProxyURL          *url.URL
	SkipSSLValidation bool

	RetryWaitMin time.Duration
	RetryWaitMax time.Duration

	ContentEncoding ContentEncoding // TODO: make this per request
}

ClientHost specifies an host that the client communicates with.

type ContentEncoding

type ContentEncoding interface {
	// contains filtered or unexported methods
}

ContentEncoding encodes the payload

var IdentityContentType ContentEncoding = &identityContentType{}

IdentityContentType encodes the payload using the identity function

type GzipContentEncoding

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

GzipContentEncoding encodes the payload using gzip algorithm

func NewGzipContentEncoding

func NewGzipContentEncoding(level int) *GzipContentEncoding

NewGzipContentEncoding creates a new Gzip content type

type HTTPResponse

type HTTPResponse struct {
	Response       *http.Response
	RequestPayload []byte
	Err            error
}

HTTPResponse is used to represent the response from the request

type RetryableHTTPClient

type RetryableHTTPClient interface {
	Get(path string) *HTTPResponse
	Put(path string, body []byte) *HTTPResponse
	Post(path string, body []byte) *HTTPResponse
	GetClient() *http.Client
}

RetryableHTTPClient describes the functionality of a http client with retries and backoff

func NewHTTPClient

func NewHTTPClient(host *ClientHost) RetryableHTTPClient

NewHTTPClient returns a RetryableHTTPClient containing a http.Client configured with the Agent options.

type StackStateClient

type StackStateClient struct {
	RetryableHTTPClient
}

StackStateClient creates a wrapper around the RetryableHTTPClient that is used for communication with StackState over http(s)

func NewStackStateClient

func NewStackStateClient(host *ClientHost) *StackStateClient

NewStackStateClient returns a RetryableHTTPClient containing a http.Client configured with the Agent options.

Jump to

Keyboard shortcuts

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