meshdial

package
v0.6.78 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package meshdial dials the gRPC channels of the mesh: a service's api.MTLS port, a platform port. It is what Root.DialService and Root.DialPlatform build on, and what backplane and the SDK dial with.

The channel resolves its host itself rather than through gRPC's DNS resolver, whose re-resolution waits 30 s after the last lookup (a process-wide setting): when a peer restarts and its address moves (a container's IP reassigned, possibly to another service, whose identity the handshake refuses), the channel looks the name up again within MinResolveInterval, retries a failing lookup within RetryMax and reconnects from ConnectBase up to ConnectMax — seconds, not minutes. Nothing process-wide is changed.

Calls are not retried: a call made while the channel is reconnecting fails with Unavailable unless it waits for readiness, bounded by its deadline:

ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
_, err := client.Get(ctx, req, grpc.WaitForReady(true))

Index

Constants

View Source
const (
	// MinResolveInterval is the least time between two lookups of a host:
	// how soon a channel whose peer refused it looks again.
	MinResolveInterval = 500 * time.Millisecond
	// RetryMax bounds the wait before a failed lookup is retried (it starts
	// at MinResolveInterval and grows).
	RetryMax = 5 * time.Second
)

Timings of a channel.

View Source
const (
	ConnectBase    = 250 * time.Millisecond
	ConnectMax     = 5 * time.Second
	ConnectTimeout = 5 * time.Second
)

How a channel reconnects: from ConnectBase up to ConnectMax, each attempt bounded by ConnectTimeout.

Variables

This section is empty.

Functions

func Dial

Dial is a channel to addr — host:port, the host a name or an IP — with creds and opts (applied last). An addr with a scheme (dns:///, unix:) goes to gRPC's own resolver unchanged, with the same reconnection. The environment's proxy (HTTPS_PROXY) is not used: a mesh address is the installation's own. Nothing connects until the first call or Connect.

Types

type Dialer

type Dialer struct{ Lookup Lookup }

Dialer is Dial with its host names resolved by Lookup (nil: the system's resolver): tests, a custom discovery.

func (Dialer) Dial

func (d Dialer) Dial(addr string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (
	*grpc.ClientConn, error,
)

Dial is Dial of the dialer.

type Lookup

type Lookup func(ctx context.Context, host string) ([]string, error)

Lookup resolves a host name to its IP addresses.

Jump to

Keyboard shortcuts

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