metadata

package
v0.0.0-...-a1881e9 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 7

Documentation

Index

Constants

View Source
const (
	VersionKey                       = "version"
	SessionRecordingFormatContextKey = "session-recording-format"
)

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 SessionRecordingFormatFromContext

func SessionRecordingFormatFromContext(ctx context.Context) string

SessionRecordingFormatFromContext returns the format of the accessed session recording (if present).

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 StreamServerInterceptor

func StreamServerInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

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

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

UnaryServerInterceptor intercepts a gRPC server unary call and adds default metadata to the context.

func UserAgentFromContext

func UserAgentFromContext(ctx context.Context) string

UserAgentFromContext returns the user agent from GRPC client metadata.

func VersionFromMetadata

func VersionFromMetadata(md metadata.MD) (string, bool)

VersionFromMetadata attempts to extract the standard version metadata value that is added to client and server headers by the interceptors in this package.

func WithSessionRecordingFormatContext

func WithSessionRecordingFormatContext(ctx context.Context, format string) context.Context

WithSessionRecordingFormatContext returns a context.Context containing the format of the accessed session recording.

func WithUserAgentFromTeleportComponent

func WithUserAgentFromTeleportComponent(component string) grpc.DialOption

WithUserAgentFromTeleportComponent returns a grpc.DialOption that reports the Teleport component and the API version for user agent.

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