outbound

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package outbound provides controlled clients for outbound HTTP calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstrumentTransport

func InstrumentTransport(base http.RoundTripper) http.RoundTripper

InstrumentTransport adds bounded HTTP client spans and metrics without changing the base transport's security, timeout or redirect policy. A nil transport uses http.DefaultTransport; wrapping its own result is idempotent. It propagates only W3C trace context, never baggage or incoming trace headers. Ordinary spans end at response-body EOF/Close; an HTTP 101 span ends at the handshake and leaves the upgraded bidirectional body unchanged.

Types

type Client

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

Client wraps a reusable HTTP client without exposing mutable security policy.

func NewClient

func NewClient(options Options) (*Client, error)

NewClient builds a client with TLS verification, HTTP(S)-only requests, redirect refusal, and bounded telemetry. It adds no application-level retries; standard library transport behavior is otherwise unchanged.

func (*Client) CloseIdleConnections

func (c *Client) CloseIdleConnections()

CloseIdleConnections releases pooled connections owned by this client.

func (*Client) Do

func (c *Client) Do(request *http.Request) (*http.Response, error)

Do performs one request. The request context controls cancellation and deadline; response bodies remain the caller's responsibility to close.

type HTTPConfig

type HTTPConfig struct {
	Timeout               time.Duration `koanf:"timeout" yaml:"timeout"`
	DialTimeout           time.Duration `koanf:"dial_timeout" yaml:"dial_timeout"`
	TLSHandshakeTimeout   time.Duration `koanf:"tls_handshake_timeout" yaml:"tls_handshake_timeout"`
	ResponseHeaderTimeout time.Duration `koanf:"response_header_timeout" yaml:"response_header_timeout"`
	IdleConnTimeout       time.Duration `koanf:"idle_conn_timeout" yaml:"idle_conn_timeout"`
	MaxIdleConns          int           `koanf:"max_idle_conns" yaml:"max_idle_conns"`
	MaxIdleConnsPerHost   int           `koanf:"max_idle_conns_per_host" yaml:"max_idle_conns_per_host"`
	MaxConnsPerHost       int           `koanf:"max_conns_per_host" yaml:"max_conns_per_host"`
}

HTTPConfig is the shared YAML-decodable HTTP connection budget for outbound, unary contract, SSE and WebSocket clients. Zero fields retain standard-library transport defaults. Timeout bounds the entire HTTP response body; leave it zero for streams and use their explicit stream budgets instead. Credentials and TLS trust are supplied separately by trusted application code, never by this config.

func (HTTPConfig) HTTPClient

func (cfg HTTPConfig) HTTPClient() (*http.Client, error)

HTTPClient constructs an independent standard transport for an adapter to validate and instrument. Pass the result to SecureClientOptions.HTTPClient or a generated client; this configuration-only helper does not add credentials, instrumentation or redirect policy. Trusted TLS roots can be set on its *http.Transport before handing it to an adapter. Callers must close idle connections when the client is no longer used.

type Options

type Options struct {
	Timeout   time.Duration
	Transport *http.Transport
}

Options configures a reusable outbound HTTP client. A supplied transport is cloned; custom RoundTrippers and TLS bypasses are intentionally unsupported.

Jump to

Keyboard shortcuts

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