share

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRPCPath is used by ServeHTTP.
	DefaultRPCPath = "/_rpcx_"

	// AuthKey is used in metadata.
	AuthKey = "__AUTH"

	// OpentracingSpanServerKey key in service context
	OpentracingSpanServerKey = "opentracing_span_server_key"
	// OpentracingSpanClientKey key in client context
	OpentracingSpanClientKey = "opentracing_span_client_key"

	// OpencensusSpanServerKey key in service context
	OpencensusSpanServerKey = "opencensus_span_server_key"
	// OpencensusSpanClientKey key in client context
	OpencensusSpanClientKey = "opencensus_span_client_key"
	// OpencensusSpanRequestKey span key in request meta
	OpencensusSpanRequestKey = "opencensus_span_request_key"
)

Variables

View Source
var (
	// Codecs are codecs supported by rpcx. You can add customized codecs in Codecs.
	Codecs = map[protocol.SerializeType]codec.Codec{
		protocol.SerializeNone: &codec.ByteCodec{},
		protocol.JSON:          &codec.JSONCodec{},
		protocol.ProtoBuffer:   &codec.PBCodec{},
		protocol.MsgPack:       &codec.MsgpackCodec{},
		protocol.Thrift:        &codec.ThriftCodec{},
	}
)
View Source
var ReqMetaDataKey = ContextKey("__req_metadata")

ReqMetaDataKey is used to set metatdata in context of requests.

View Source
var ResMetaDataKey = ContextKey("__res_metadata")

ResMetaDataKey is used to set metatdata in context of responses.

Functions

func GetOpencensusSpanContextFromContext

func GetOpencensusSpanContextFromContext(ctx context.Context) (*trace.SpanContext, error)

GetOpencensusSpanContextFromContext get opencensus.trace.SpanContext from context.Context.

func GetSpanContextFromContext

func GetSpanContextFromContext(ctx context.Context) (opentracing.SpanContext, error)

GetSpanContextFromContext get opentracing.SpanContext from context.Context.

func RegisterCodec

func RegisterCodec(t protocol.SerializeType, c codec.Codec)

RegisterCodec register customized codec.

Types

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

Context is a rpcx customized Context that can contains multiple values.

func NewContext

func NewContext(ctx context.Context) *Context

func WithLocalValue

func WithLocalValue(ctx *Context, key, val interface{}) *Context

func WithValue

func WithValue(parent context.Context, key, val interface{}) *Context

func (*Context) SetValue

func (c *Context) SetValue(key, val interface{})

func (*Context) String

func (c *Context) String() string

func (*Context) Value

func (c *Context) Value(key interface{}) interface{}

type ContextKey

type ContextKey string

ContextKey defines key type in context.

Jump to

Keyboard shortcuts

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