Documentation ¶
Index ¶
- Constants
- func BuildForwardContext(ctx context.Context, addr string) context.Context
- func GetClientConn(ctx context.Context, addr string, tlsCfg *tls.Config, do ...grpc.DialOption) (*grpc.ClientConn, error)
- func GetOrCreateGRPCConn(ctx context.Context, clientConns *sync.Map, addr string, ...) (*grpc.ClientConn, error)
Constants ¶
const (
// ForwardMetadataKey is used to record the forwarded host of TM.
ForwardMetadataKey = "tm-forwarded-host"
)
Variables ¶
This section is empty.
Functions ¶
func BuildForwardContext ¶
BuildForwardContext creates a context with receiver metadata information. It is used in client side.
func GetClientConn ¶
func GetClientConn(ctx context.Context, addr string, tlsCfg *tls.Config, do ...grpc.DialOption) (*grpc.ClientConn, error)
GetClientConn returns a gRPC client connection. creates a client connection to the given target. By default, it's a non-blocking dial (the function won't wait for connections to be established, and connecting happens in the background). To make it a blocking dial, use WithBlock() dial option.
In the non-blocking case, the ctx does not act against the connection. It only controls the setup steps.
In the blocking case, ctx can be used to cancel or expire the pending connection. Once this function returns, the cancellation and expiration of ctx will be noop. Users should call ClientConn.Close to terminate all the pending operations after this function returns.
func GetOrCreateGRPCConn ¶
func GetOrCreateGRPCConn(ctx context.Context, clientConns *sync.Map, addr string, tlsCfg *tlsutil.TLSConfig, opt ...grpc.DialOption) (*grpc.ClientConn, error)
GetOrCreateGRPCConn returns the corresponding grpc client connection of the given addr. Returns the old one if's already existed in the clientConns; otherwise creates a new one and returns it.
Types ¶
This section is empty.