httpf

package
v0.0.0-...-ef84630 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 23 Imported by: 0

README

httpf

This packeage implements the HTTP client manager for Auth Proxy. Auth proxy uses gentlemen for http clients, and this package automatically applies middleware based on the configuration for session proxy.

Documentation

Index

Constants

View Source
const (
	RequestTypeGlobal = common.RequestTypeGlobal
	RequestTypeProxy  = common.RequestTypeProxy
	RequestTypeOAuth  = common.RequestTypeOAuth
	RequestTypePublic = common.RequestTypePublic
	RequestTypeProbe  = common.RequestTypeProbe
)
View Source
const LabelValueOther = "other"

LabelValueOther is the placeholder substituted for label values that exceed the configured metric_dimension_value_cap. Bounds the cardinality of metric streams under runaway label-value churn.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor interface {
	GetId() apid.ID
	GetNamespace() string
	GetLabels() map[string]string
}

Actor is the minimum surface needed to attach an actor's identity and labels to an outgoing request. The full Actor type lives in apauth/core (it carries permissions, session info, etc.) but for label-snapshot purposes the request-info factory only needs the id, namespace, and label set. A nil Actor (e.g. background token-refresh requests where no actor initiated the call) is a valid input for ForActor.

type Connection

type Connection interface {
	GetId() apid.ID
	GetNamespace() string
	GetConnectorId() apid.ID
	GetConnectorVersion() uint64
	GetLabels() map[string]string
}

type ConnectorVersion

type ConnectorVersion interface {
	GetId() apid.ID
	GetNamespace() string
	GetVersion() uint64
}

type F

type F interface {
	New() *gentleman.Client
	ForRequestInfo(ri RequestInfo) F
	ForRequestType(rt RequestType) F
	ForConnectorVersion(cv ConnectorVersion) F
	ForConnection(cv Connection) F
	ForActor(actor Actor) F
	ForLabels(labels map[string]string) F
}

func CreateFactory

func CreateFactory(
	cfg config.C,
	r apredis.Client,
	requestLog RoundTripperFactory,
	logger *slog.Logger,
	additionalMiddlewares ...RoundTripperFactory,
) F

type GettableConnectorVersion

type GettableConnectorVersion interface {
	GetConnectorVersionEntity() ConnectorVersion
}

type RateLimitConfigProvider

type RateLimitConfigProvider interface {
	GetRateLimitConfig() *connectors.RateLimiting
}

RateLimitConfigProvider is an optional interface that connections can implement to provide rate limiting configuration from the connector definition.

type RequestInfo

type RequestInfo struct {
	Namespace        string
	Type             RequestType
	ConnectorId      apid.ID
	ConnectorVersion uint64
	ConnectionId     apid.ID
	Labels           map[string]string

	// RateLimiting is the rate limiting configuration for the connector, if available.
	// Nil means use default behavior (enabled with standard Retry-After parsing).
	RateLimiting *connectors.RateLimiting

	// PropagateTraceContext is the per-connection / per-connector override
	// for W3C trace context injection on outbound calls. nil means "use the
	// global default from telemetry.propagation.inject_outbound_default".
	// Populated by ForConnection from a connection whose connector defines
	// telemetry.propagate_trace_context.
	PropagateTraceContext *bool
}

type RequestType

type RequestType = common.RequestType

RequestType is re-exported from schema/common so callers within the runtime layers can keep referring to httpf.RequestType while the canonical definition (and its validation) lives alongside the rest of the schema types.

type RoundTripperFactory

type RoundTripperFactory interface {
	// NewRoundTripper returns a new http.RoundTripper. This method can return
	// nil to imply it does not want to participate in the request.
	NewRoundTripper(ri RequestInfo, transport http.RoundTripper) http.RoundTripper
}

func NewTelemetryFactory

func NewTelemetryFactory(providers *aptelemetry.Providers, cfg *sconfig.Telemetry) (RoundTripperFactory, error)

NewTelemetryFactory returns a RoundTripperFactory that emits an OTel client span per outbound request plus the proxy duration / bytes-in / bytes-out histograms specified by #232. Labels carried on RequestInfo are projected onto telemetry per the two independent allowlists in telemetry.proxy.{span_attribute_labels,metric_dimension_labels}; missing keys produce no attribute / dimension at all.

When the providers are nil / in no-op mode, or when both trace and metric signals are disabled in cfg, NewTelemetryFactory returns (nil, nil) so the caller can skip adding the middleware — the outbound path stays a true no-op for unconfigured deployments.

type TracePropagationProvider

type TracePropagationProvider interface {
	PropagateTraceContext() *bool
}

TracePropagationProvider is an optional interface implemented by connections whose connector definition specifies a per-connector override for outbound W3C trace context injection. Return nil to inherit the global default.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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