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 ¶
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.
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 ¶
func Dial(addr string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error)
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.