rkgrpcctx

package
v2.2.22 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Overview

Package rkgrpcctx provides utility functions deal with metadata in RPC context

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHeaderToClient

func AddHeaderToClient(ctx context.Context, key, value string)

AddHeaderToClient Headers that would be sent to client.

func EndTraceSpan

func EndTraceSpan(ctx context.Context, span trace.Span, success bool)

EndTraceSpan End span

func GetCursor added in v2.0.3

func GetCursor(ctx context.Context) *rkcursor.Cursor

GetCursor create rkcursor.Cursor instance

func GetEntryName

func GetEntryName(ctx context.Context) string

GetEntryName Extract the call-scoped entry name.

func GetEvent

func GetEvent(ctx context.Context) rkquery.Event

GetEvent Extract the call-scoped EventData from context.

func GetIncomingHeaders

func GetIncomingHeaders(ctx context.Context) metadata.MD

GetIncomingHeaders Extract call-scoped incoming headers

func GetJwtToken

func GetJwtToken(ctx context.Context) *jwt.Token

GetJwtToken return jwt.Token if exists

func GetLogger

func GetLogger(ctx context.Context) *zap.Logger

GetLogger Extract the call-scoped zap logger from context.

func GetRequestId

func GetRequestId(ctx context.Context) string

GetRequestId Get request id in outgoing metadata.

func GetTraceId

func GetTraceId(ctx context.Context) string

GetTraceId Get trace id in context.

func GetTraceSpan

func GetTraceSpan(ctx context.Context) trace.Span

GetTraceSpan Extract the call-scoped span from context.

func GetTracer

func GetTracer(ctx context.Context) trace.Tracer

GetTracer Extract the call-scoped tracer from context.

func GetTracerPropagator

func GetTracerPropagator(ctx context.Context) propagation.TextMapPropagator

GetTracerPropagator Extract the call-scoped span processor from middleware.

func GetTracerProvider

func GetTracerProvider(ctx context.Context) trace.TracerProvider

GetTracerProvider Extract the call-scoped tracer provider from context.

func GormCtx added in v2.2.6

func GormCtx(ctx context.Context) context.Context

func InjectSpanToHttpRequest

func InjectSpanToHttpRequest(ctx context.Context, req *http.Request)

InjectSpanToHttpRequest Inject current trace information into http request

func InjectSpanToNewContext

func InjectSpanToNewContext(ctx context.Context) context.Context

InjectSpanToNewContext Inject current trace information into context

func NewTraceSpan

func NewTraceSpan(ctx context.Context, name string) trace.Span

NewTraceSpan Start a new span

func SetPointerCreator added in v2.2.16

func SetPointerCreator(creator rkcursor.PointerCreator)

SetPointerCreator override rkcursor.PointerCreator

Types

type GrpcMetadataCarrier

type GrpcMetadataCarrier struct {
	Md *metadata.MD
}

GrpcMetadataCarrier Grpc metadata carrier which will carries tracing info into grpc metadata to server side.

func (*GrpcMetadataCarrier) Get

func (carrier *GrpcMetadataCarrier) Get(key string) string

Get value with key from grpc metadata.

func (*GrpcMetadataCarrier) Keys

func (carrier *GrpcMetadataCarrier) Keys() []string

Keys List keys in grpc metadata.

func (*GrpcMetadataCarrier) Set

func (carrier *GrpcMetadataCarrier) Set(key string, value string)

Set value with key into grpc metadata.

type WrappedServerStream

type WrappedServerStream struct {
	grpc.ServerStream
	// WrappedContext is the wrapper's own Context. You can assign it.
	WrappedContext context.Context
}

WrappedServerStream is a thin wrapper around grpc.ServerStream that allows modifying context.

func WrapServerStream

func WrapServerStream(stream grpc.ServerStream) *WrappedServerStream

WrapServerStream returns a ServerStream that has the ability to overwrite context.

func (*WrappedServerStream) Context

func (w *WrappedServerStream) Context() context.Context

Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()

Jump to

Keyboard shortcuts

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