grpcutil

package
v0.0.0-...-a6ee7d6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ForwardMetadataKey is used to record the forwarded host of TM.
	ForwardMetadataKey = "tm-forwarded-host"
)

Variables

This section is empty.

Functions

func BuildForwardContext

func BuildForwardContext(ctx context.Context, addr string) context.Context

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.

Jump to

Keyboard shortcuts

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