Help us shape the future of Go! Take the 2026 Go Developer Survey

dialer

package
v1.22.88 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ThrottleRps       uint32        `json:"throttleRps"`
	ConnectionTimeout time.Duration `json:"connectionTimeout"`
}

type DNSCacheConfig added in v1.22.84

type DNSCacheConfig struct {
	// TTL is how long resolved IPs are cached.
	TTL time.Duration `json:"ttl"`
	// MaxEntries is the maximum number of cached resolutions.
	MaxEntries int `json:"maxEntries"`
	// ResolveTimeout is the timeout for DNS resolution.
	ResolveTimeout time.Duration `json:"resolveTimeout"`
}

DNSCacheConfig configures the DNS resolution cache.

func DefaultDNSCacheConfig added in v1.22.84

func DefaultDNSCacheConfig() DNSCacheConfig

DefaultDNSCacheConfig returns sensible defaults for DNS caching.

type Dialer

type Dialer interface {
	// If [ctx] is canceled, gives up trying to connect to [ip]
	// and returns an error.
	Dial(ctx context.Context, ip netip.AddrPort) (net.Conn, error)
}

Dialer attempts to create a connection with the provided IP/port pair

func NewDialer

func NewDialer(network string, dialerConfig Config, logger log.Logger) Dialer

NewDialer returns a new Dialer that calls net.Dial with the provided network. [network] is the network passed into Dial. Should probably be "TCP". [dialerConfig.connectionTimeout] gives the timeout when dialing an IP. [dialerConfig.throttleRps] gives the max number of outgoing connection attempts/second. If [dialerConfig.throttleRps] == 0, outgoing connections aren't rate-limited.

type EndpointDialer added in v1.22.84

type EndpointDialer interface {
	// DialEndpoint dials an endpoint that can be either IP or hostname based.
	DialEndpoint(ctx context.Context, endpoint ips.Endpoint) (net.Conn, error)

	// Dial is the legacy IP-only dial method for backward compatibility.
	Dial(ctx context.Context, ip netip.AddrPort) (net.Conn, error)
}

EndpointDialer attempts to create a connection with either an IP:port or hostname:port.

func NewEndpointDialer added in v1.22.84

func NewEndpointDialer(network string, config EndpointDialerConfig, logger log.Logger) EndpointDialer

NewEndpointDialer creates a dialer that supports both IP and hostname endpoints.

type EndpointDialerConfig added in v1.22.84

type EndpointDialerConfig struct {
	Config
	DNSConfig DNSCacheConfig `json:"dnsConfig"`
}

EndpointDialerConfig extends Config with DNS settings.

Jump to

Keyboard shortcuts

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