metadata

package
v7.0.0-...-185e5fd Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionKey = "version"
)

Variables

This section is empty.

Functions

func AddMetadataToContext

func AddMetadataToContext(ctx context.Context, raw map[string]string) context.Context

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

func ClientVersionFromContext(ctx context.Context) (string, bool)

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).

Jump to

Keyboard shortcuts

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