client

package
v3.38.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: MIT Imports: 26 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldSpecs added in v3.9.0

func FieldSpecs() docs.FieldSpecs

FieldSpecs returns a map of field specs for an HTTP type.

func OptSetCloseChan

func OptSetCloseChan(c <-chan struct{}) func(*Type)

OptSetCloseChan sets a channel that when closed will interrupt any blocking calls within the client.

func OptSetHTTPTransport

func OptSetHTTPTransport(transport *http.Transport) func(*Type)

OptSetHTTPTransport sets the HTTP Transport to use. NOTE: This setting will override any configured TLS options.

WARNING: DEPRECATED, use OptSetRoundTripper instead. TODO: V4 Remove this

func OptSetLogger

func OptSetLogger(log log.Modular) func(*Type)

OptSetLogger sets the logger to use.

func OptSetManager

func OptSetManager(mgr types.Manager) func(*Type)

OptSetManager sets the manager to use.

func OptSetRoundTripper added in v3.17.0

func OptSetRoundTripper(rt http.RoundTripper) func(*Type)

OptSetRoundTripper sets the *client.Transport to use for HTTP requests. NOTE: This setting will override any configured TLS options.

func OptSetStats

func OptSetStats(stats metrics.Type) func(*Type)

OptSetStats sets the metrics aggregator to use.

Types

type Config

type Config struct {
	URL                 string            `json:"url" yaml:"url"`
	Verb                string            `json:"verb" yaml:"verb"`
	Headers             map[string]string `json:"headers" yaml:"headers"`
	CopyResponseHeaders bool              `json:"copy_response_headers" yaml:"copy_response_headers"`
	RateLimit           string            `json:"rate_limit" yaml:"rate_limit"`
	Timeout             string            `json:"timeout" yaml:"timeout"`
	Retry               string            `json:"retry_period" yaml:"retry_period"`
	MaxBackoff          string            `json:"max_retry_backoff" yaml:"max_retry_backoff"`
	NumRetries          int               `json:"retries" yaml:"retries"`
	BackoffOn           []int             `json:"backoff_on" yaml:"backoff_on"`
	DropOn              []int             `json:"drop_on" yaml:"drop_on"`
	SuccessfulOn        []int             `json:"successful_on" yaml:"successful_on"`
	TLS                 tls.Config        `json:"tls" yaml:"tls"`
	ProxyURL            string            `json:"proxy_url" yaml:"proxy_url"`
	auth.Config         `json:",inline" yaml:",inline"`
	OAuth2              auth.OAuth2Config `json:"oauth2" yaml:"oauth2"`
}

Config is a configuration struct for an HTTP client.

func NewConfig

func NewConfig() Config

NewConfig creates a new Config with default values.

type Type

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

Type is an output type that pushes messages to Type.

func New

func New(conf Config, opts ...func(*Type)) (*Type, error)

New creates a new Type.

func (*Type) CloseAsync added in v3.30.0

func (h *Type) CloseAsync()

CloseAsync closes the HTTP client and all managed resources.

func (*Type) CreateRequest

func (h *Type) CreateRequest(msg types.Message) (req *http.Request, err error)

CreateRequest creates an HTTP request out of a single message.

func (*Type) Do

func (h *Type) Do(msg types.Message) (*http.Response, error)

Do attempts to create and perform an HTTP request from a message payload. This attempt may include retries, and if all retries fail an error is returned.

func (*Type) DoWithContext added in v3.33.0

func (h *Type) DoWithContext(ctx context.Context, msg types.Message) (res *http.Response, err error)

DoWithContext is the context aware version of Do

func (*Type) ParseResponse

func (h *Type) ParseResponse(res *http.Response) (resMsg types.Message, err error)

ParseResponse attempts to parse an HTTP response into a 2D slice of bytes.

func (*Type) Send

func (h *Type) Send(msg types.Message) (types.Message, error)

Send attempts to send a message to an HTTP server, this attempt may include retries, and if all retries fail an error is returned. The message payload can be nil, in which case an empty body is sent. The response will be parsed back into a message, meaning mulitpart content handling is done for you.

If the response body is empty the message returned is nil.

func (*Type) SendWithContext added in v3.33.0

func (h *Type) SendWithContext(ctx context.Context, msg types.Message) (types.Message, error)

SendWithContext is the context aware version of Send

Jump to

Keyboard shortcuts

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