netopts

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package netopts holds the TransportOptions value type and its validation. It exists to break the import cycle between `internal/app` (which declares the consumer-defined Transport interface) and `internal/adapter/transport` (which implements it).

The DDD layering rule forbids `internal/app` from importing `internal/adapter/transport`, so the value type that flows through the Transport interface signature lives here — a leaf package both callers can import without cycling.

Field semantics are documented on the type itself. The app layer passes values through its transport interface, and the transport adapter applies each non-zero setting to outbound and accepted TCP connections.

Index

Constants

This section is empty.

Variables

View Source
var ErrTransportOptionsInvalid = errors.New("netopts: TransportOptions invalid")

ErrTransportOptionsInvalid indicates a TransportOptions field carried a negative value (durations, probe count, or buffer size). Surfaced at constructor time so the caller cannot build a working Importer/Exporter with malformed options.

Functions

func Validate

func Validate(opts TransportOptions) error

Validate returns ErrTransportOptionsInvalid wrapped with the offending field name if any duration, probe count, or buffer size is negative. Zero values are always accepted so a caller can opt into individual knobs without specifying every field.

Types

type TransportOptions

type TransportOptions struct {
	// DialConnectTimeout caps the TCP connect phase on outbound
	// importer dials. Zero defers to net.Dialer's zero-value behavior
	// (no app-level cap). Negative is rejected by Validate.
	DialConnectTimeout time.Duration

	// TCPKeepAliveIdle is the idle period before TCP keepalive probes
	// start. Zero leaves the OS default in place. Negative rejected.
	TCPKeepAliveIdle time.Duration

	// TCPKeepAliveInterval is the spacing between TCP keepalive
	// probes. Zero leaves the OS default in place. Negative rejected.
	TCPKeepAliveInterval time.Duration

	// TCPKeepAliveProbes is the count of unanswered keepalive probes
	// after which the kernel declares the connection dead. Zero leaves
	// the OS default in place. Negative rejected.
	TCPKeepAliveProbes int

	// SendBufferBytes is the requested SO_SNDBUF on outbound dials and
	// accepted listener connections. Zero inherits the kernel default.
	// Linux doubles SO_SNDBUF internally; adapter-side assertions must
	// allow `actual >= requested`. Negative rejected.
	SendBufferBytes int

	// ReceiveBufferBytes is the requested SO_RCVBUF (same semantics as
	// SendBufferBytes). Negative rejected.
	ReceiveBufferBytes int

	// ReadDeadline is the static read deadline applied to userspace
	// OP_REQ_*/OP_REP_* handshakes; it is cleared before any kernel fd
	// handoff. Zero means no app-level read deadline. Negative
	// rejected.
	ReadDeadline time.Duration

	// WriteDeadline mirrors ReadDeadline for the write side.
	WriteDeadline time.Duration
}

TransportOptions carries TCP-level tuning knobs for the transport adapter that backs Importer and Exporter. Each field's zero value means "inherit current behavior / kernel default", so an unset TransportOptions struct keeps v1.0.0 wire behavior unchanged.

Jump to

Keyboard shortcuts

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