propagator

package
v5.0.0-...-4117378 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalMeta

func CanonicalMeta(ctx context.Context, name string) (string, bool)

CanonicalMeta extract header name or its lowercase version

func ContextStreamClientInterceptor

func ContextStreamClientInterceptor(modifier OutgoingContextModifier) grpc.StreamClientInterceptor

ContextStreamClientInterceptor is a grpc client middleware to modify context

func ContextStreamServerInterceptor

func ContextStreamServerInterceptor(modifier IncomingContextModifier) grpc.StreamServerInterceptor

ContextStreamServerInterceptor wraps an IncomingContextModifier to create a grpc.StreamServerInterceptor.

func ContextUnaryClientInterceptor

func ContextUnaryClientInterceptor(modifier OutgoingContextModifier) grpc.UnaryClientInterceptor

ContextUnaryClientInterceptor is a grpc client middleware to modify context

func ContextUnaryServerInterceptor

func ContextUnaryServerInterceptor(modifier IncomingContextModifier) grpc.UnaryServerInterceptor

ContextUnaryServerInterceptor wraps an IncomingContextModifier to create a grpc.UnaryServerInterceptor.

func ForkContext

func ForkContext(ctx, parent context.Context) context.Context

ForkContext copies all necessary dependencies using the internal ContextInjector registry

func ForkOneKey

func ForkOneKey(key any, child, parent context.Context) context.Context

func ForkedBackgroundWithMeta

func ForkedBackgroundWithMeta(ctx context.Context) context.Context

func Get

func Get[T any](ctx context.Context, key any, out *T) bool

Get is a generic context-getter to an expected type

func HttpContextMiddleware

func HttpContextMiddleware(modifier IncomingContextModifier) func(http.Handler) http.Handler

func MetaKeysIncomingContext

func MetaKeysIncomingContext(ctx context.Context, prefix string) (context.Context, bool, error)

MetaKeysIncomingContext looks up for keys in grpc metadata IncomingContext and set them in standard metadata map. Keys can be exact matches or prefixes like "something*"

func MetaStreamClientInterceptor

func MetaStreamClientInterceptor(prefix string) grpc.StreamClientInterceptor

func MetaUnaryClientInterceptor

func MetaUnaryClientInterceptor(prefix string) grpc.UnaryClientInterceptor

func MinioMetaFromContext

func MinioMetaFromContext(ctx context.Context, userKey string, forEvents ...bool) (md map[string]string, ok bool)

MinioMetaFromContext prepares metadata for minio client. If forEvents is passed, it replies with the complete set of metadata

func MustWithHint

func MustWithHint[T any](ctx context.Context, key any, hint string) T

MustWithHint performs a Get() and panics with a hint message if not found

func NewContext

func NewContext(ctx context.Context, md map[string]string) context.Context

func RegisterContextInjector

func RegisterContextInjector(injector ContextInjector)

RegisterContextInjector appends a ContextInjector to the internal registry

func RegisterKeyInjector

func RegisterKeyInjector[T any](key any)

RegisterKeyInjector creates a context injector that copies the type T from parent to child context

func With

func With[T any](ctx context.Context, key any, t T) context.Context

With is a generic context-setter

func WithAdditionalMetadata

func WithAdditionalMetadata(ctx context.Context, meta map[string]string) context.Context

WithAdditionalMetadata retrieves existing meta, adds new key/values to the map and produces a new context It enforces case-conflicts on all keys

func WithUserNameMetadata

func WithUserNameMetadata(ctx context.Context, userKey string, userName string) context.Context

WithUserNameMetadata appends a username to both the context metadata and as context key.

Types

type ContextInjector

type ContextInjector func(ctx, parent context.Context) context.Context

type IncomingContextModifier

type IncomingContextModifier func(ctx context.Context) (context.Context, bool, error)

IncomingContextModifier modifies context and returns a new context, true if context was modified, or an error

type Metadata

type Metadata map[string]string

func FromContextCopy

func FromContextCopy(ctx context.Context) (Metadata, bool)

FromContextCopy returns as COPY of the internal metadata, that can be subsequently modified

func FromContextRead

func FromContextRead(ctx context.Context) (Metadata, bool)

FromContextRead returns internal metadata as is. Beware of not modifying it to avoid r/w concurrent access, in that case you must use FromContextCopy instead.

type OutgoingContextModifier

type OutgoingContextModifier func(ctx context.Context) context.Context

OutgoingContextModifier can be used to modify context during a grpc client request

Jump to

Keyboard shortcuts

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