client

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultTransport

func DefaultTransport() *http.Transport

DefaultTransport returns a new http.Transport which is a clone of the http.DefaultTransport. This is to avoid accidental transport overrides because http.DefaultTransport. is a package global.

Types

type HTTP

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

HTTP is an HTTP client.

func NewHTTP

func NewHTTP(opts ...HTTPOption) *HTTP

NewHTTP creates a new HTTP client and returns it.

func (*HTTP) Do

func (h *HTTP) Do(req *http.Request) (*http.Response, error)

Do dispatches the HTTP request to the remote endpoint.

type HTTPOption

type HTTPOption func(*HTTPOptions)

HTTPOption is HTTP client functional option.

func WithHTTPClient

func WithHTTPClient(c *http.Client) HTTPOption

WithHTTPClient sets the HTTP client to c.

func WithLimiter

func WithLimiter(l Limiter) HTTPOption

WithLimiter sets the http rate limiter to l.

type HTTPOptions

type HTTPOptions struct {
	HTTPClient *http.Client
	Limiter    Limiter
}

HTTPOptions configure the HTTP client.

type Limiter

type Limiter interface {
	// Wait must block until limiter
	// permits another request to proceed.
	Wait(context.Context) error
}

Limiter is used to apply API rate limits. NOTE: you can use off the shelf limiter from https://pkg.go.dev/golang.org/x/time/rate#Limiter

Jump to

Keyboard shortcuts

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