roundtripper

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(c Config) (backend.Client, error)

NewClient returns a new Client instance constructed from the user specified configuration.

func WithAuditID

func WithAuditID(delegate backend.Client) backend.Client

WithAuditID generates an audit ID and attaches it to the appropriate request header.

func WithGotConnTrace

func WithGotConnTrace(delegate backend.Client) backend.Client

WithGotConnTrace attaches a 'GotConn' and 'DNSDone' client trace to the given request.

 GotConn: this client trace is called after a successful connection is
	  obtained, using this trace we can infer whether this connection has
	  been previously used for another HTTP request.
 DNSDone: this client trace is called when a DNS lookup ends, and we
   can obtain the error that occurred during the DNS lookup, if any.

This function will attach the data obtained from the client trace to the request context so it can be retrieved later.

func WithResponseBodyReader

func WithResponseBodyReader(delegate backend.Client) backend.Client

WithResponseBodyReader makes an attempt to read the body of the response from the server, any error that occurs while reading the body, or while closing the underlying stream will be saved for later access.

func WithRoundTripLatencyTracking

func WithRoundTripLatencyTracking(delegate backend.Client) backend.Client

WithRoundTripLatencyTracking will measure the round trip latency incurred and save it to the context so it can be accessed later.

func WithShutdownResponseHeaderExtractor

func WithShutdownResponseHeaderExtractor(delegate backend.Client, decoder backend.HostNameDecoder) backend.Client

WithShutdownResponseHeaderExtractor adds the 'X-Openshift-If-Disruption' request header to the given request in order to opt in to receive the shutdown response header; upon receiving a response from the server it parses the 'X-OpenShift-Disruption' response header and attaches the parsed data to the request context.

format: shutdown=%t shutdown-delay-duration=%s elapsed=%s host=%s

func WithSource

func WithSource(delegate backend.Client, source string) backend.Client

WithSource sets pod name for incluster monitor.

func WithTimeout

func WithTimeout(delegate backend.Client, timeout time.Duration) backend.Client

WithTimeout will create a context with deadline that is proportional to the given timeout and assign it to the request.

func WithUserAgent

func WithUserAgent(delegate backend.Client, agent string) backend.Client

WithUserAgent sets the given 'agent' as the User Agent for this request if the 'User-Agent' request header is not already set.

func WrapClient

func WrapClient(client *http.Client, timeout time.Duration, userAgent string, shutdownResponse bool, decoder backend.HostNameDecoder, source string) backend.Client

WrapClient wraps the base http.Client object

Types

type Config

type Config struct {
	RT            http.RoundTripper
	ClientTimeout time.Duration
	UserAgent     string

	// EnableShutdownResponseHeader indicates whether to include the shutdown
	// response header extractor, this should be true only when the
	// request(s) are being sent to the kube-apiserver.
	EnableShutdownResponseHeader bool

	// HostNameDecoder, if specified, is used to decode the APIServerIdentity
	// inside the shutdown response header into the actual human readable hostname.
	HostNameDecoder backend.HostNameDecoder

	// Source contains pod name if incluster monitor is used
	Source string
}

Config holds the user specified parameters to make a new client

Jump to

Keyboard shortcuts

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