grpc

package
v1.0.2808-e6817e8 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package grpchelpers includes helpers to set up grpc connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(ctx context.Context, host, serviceName string) (*grpc.ClientConn, error)

func ProxyProofTarget

func ProxyProofTarget(host string) string

ProxyProofTarget takes the host and if there is no proxy in place in the environment at all or if there is a proxy, but we should still use it for the given url, the returned host will include the dns:// prefix.

Note if this is used to avoid traffic going via a proxy then DNS based load balancing is disabled.

A Note On Proxies.

NO_PROXY domain names can't be honored with dns scheme because of https://github.com/grpc/grpc-go/issues/3401

The following doc... https://github.com/grpc/grpc/blob/master/doc/naming.md suggests that if no scheme prefix is used then the dns is used automatically, but this is a bit misleading.

The dns scheme does a lookup for any SRV and multiple A records amongst other things, to set up a list of servers. At this point the server addresses are all in the form ip:port. The thing is - nothing is actually connected at this point, connections are made lazily. Using the dns scheme supports client side per request load balancing.

If the dns scheme is not used then in fact go grpc uses a 'passthrough' scheme, which defers name resolution to the standard (dns) resolver at connection (dial) time passing through the server name, resolving to one IP. This obviously does not support client side per call balancing.

The detection of a proxy only happens during dialing, and it is the proxy environment variables that indicate whether a proxy should be used.

In the 'passthrough' case because we have the full domain during dialing the client can compare this with the list of domains in the NO_PROXY list. However, in the full dns scheme case we only have a list of IPs which don't match anything in the NO_PROXY list - so they are duly proxied.

func ServiceConfig

func ServiceConfig(serviceName string) string

ServiceConfig returns a JSON-encoded service config. Takes a service name as defined in the service's .proto file (e.g. "package.ServiceName").

Types

This section is empty.

Jump to

Keyboard shortcuts

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