httpclient

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultApplicationName = "Ghoten"
)

Variables

This section is empty.

Functions

func GhotenUserAgent

func GhotenUserAgent(version string) string

func New

func New(ctx context.Context) *http.Client

New returns the DefaultPooledClient from the cleanhttp package that will also send a Ghoten User-Agent string.

If the given context has an active OpenTelemetry trace span associated with it then the returned client is also configured to collect traces for outgoing requests. However, those traces will be children of the span associated with the context passed _in each individual request_, rather than of the span in the context passed to this function; this function only checks for the presence of any span as a heuristic for whether the caller is in a part of the codebase that has OpenTelemetry plumbing in place, and does not actually make use of any information from that span.

func NewForRegistryRequests

func NewForRegistryRequests(ctx context.Context, retryCount int, timeout time.Duration) *retryablehttp.Client

NewForRegistryRequests is a variant of New that deals with some additional policy concerns related to "registry requests".

Exactly what constitutes a "registry request" is actually more about historical technical debt than intentional design, since these concerns were originally supposed to be handled internally within the module and provider registry clients but the implementation of that unfortunately caused the effects to "leak out" into other parts of the system, which we now preserve for backward compatibility here.

Therefore "registry requests" includes the following:

  • All requests from the client of our network service discovery protocol, even though not all discoverable services are actually "registries".
  • Requests to module registries during module installation.
  • Requests to provider registries during provider installation.

The retryCount argument specifies how many times requests from the resulting client should be automatically retried when certain transient errors occur.

The timeout argument specifies a deadline for the completion of each request made using the client.

Types

This section is empty.

Jump to

Keyboard shortcuts

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