Documentation ¶
Index ¶
- Constants
- func BuildFollowerHandleContext(ctx context.Context) context.Context
- func BuildForwardContext(ctx context.Context, url string) context.Context
- func GetClientConn(ctx context.Context, addr string, tlsCfg *tls.Config, do ...grpc.DialOption) (*grpc.ClientConn, error)
- func GetForwardedHost(ctx context.Context, f func(context.Context) (metadata.MD, bool)) string
- func GetOrCreateGRPCConn(ctx context.Context, clientConns *sync.Map, url string, tlsCfg *tls.Config, ...) (*grpc.ClientConn, error)
- func IsFollowerHandleEnabled(ctx context.Context, f func(context.Context) (metadata.MD, bool)) bool
- func UnaryBackofferInterceptor() grpc.UnaryClientInterceptor
- func UnaryCircuitBreakerInterceptor() grpc.UnaryClientInterceptor
Constants ¶
const ( // ForwardMetadataKey is used to record the forwarded host of PD. ForwardMetadataKey = "pd-forwarded-host" // FollowerHandleMetadataKey is used to mark the permit of follower handle. FollowerHandleMetadataKey = "pd-allow-follower-handle" )
Variables ¶
This section is empty.
Functions ¶
func BuildFollowerHandleContext ¶
BuildFollowerHandleContext creates a context with follower handle metadata information. It is used in client side.
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 GetForwardedHost ¶
GetForwardedHost returns the forwarded host in metadata. Only used for test.
func GetOrCreateGRPCConn ¶
func GetOrCreateGRPCConn(ctx context.Context, clientConns *sync.Map, url string, tlsCfg *tls.Config, 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.
func IsFollowerHandleEnabled ¶
IsFollowerHandleEnabled returns the forwarded host in metadata. Only used for test.
func UnaryBackofferInterceptor ¶
func UnaryBackofferInterceptor() grpc.UnaryClientInterceptor
UnaryBackofferInterceptor is a gRPC interceptor that adds a backoffer to the call.
func UnaryCircuitBreakerInterceptor ¶
func UnaryCircuitBreakerInterceptor() grpc.UnaryClientInterceptor
UnaryCircuitBreakerInterceptor is a gRPC interceptor that adds a circuit breaker to the call.
Types ¶
This section is empty.