Documentation ¶
Index ¶
- Constants
- func AddMetadataToContext(ctx context.Context, raw map[string]string) context.Context
- func ClientVersionFromContext(ctx context.Context) (string, bool)
- func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- type DisableInterceptors
Constants ¶
const (
VersionKey = "version"
)
Variables ¶
This section is empty.
Functions ¶
func AddMetadataToContext ¶
AddMetadataToContext returns a new context copied from ctx with the given raw metadata added. Metadata already set on the given context for any key will not be overridden, but new key/value pairs will always be added.
func ClientVersionFromContext ¶
ClientVersionFromContext can be called from a GRPC server method to return the client version that was added to the GRPC metadata by StreamClientInterceptor or UnaryClientInterceptor on the client.
func StreamClientInterceptor ¶
func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
StreamClientInterceptor intercepts a GRPC client stream call and adds default metadata to the context.
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
UnaryClientInterceptor intercepts a GRPC client unary call and adds default metadata to the context.
Types ¶
type DisableInterceptors ¶
type DisableInterceptors struct{}
DisableInterceptors can be set on the client context with context.WithValue(ctx, DisableInterceptors{}, struct{}{}) to stop the client interceptors from adding any metadata to the context (useful for testing).