servicecontext

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package servicecontext performs context values read/write, generally through server or client wrappers

Index

Constants

View Source
const (
	ServiceColorRest  = 32
	ServiceColorGrpc  = 35
	ServiceColorOther = 36
)
View Source
const (
	HttpMetaExtracted      = "HttpMetaExtracted"
	HttpMetaRemoteAddress  = "RemoteAddress"
	HttpMetaRequestMethod  = "RequestMethod"
	HttpMetaRequestURI     = "RequestURI"
	HttpMetaProtocol       = "HttpProtocol"
	HttpMetaUserAgent      = "UserAgent"
	HttpMetaContentType    = "ContentType"
	HttpMetaCoookiesString = "CookiesString"
	ClientTime             = "ClientTime"
	ServerTime             = "ServerTime"
)
View Source
const (
	SpanMetadataId           = "x-pydio-span-id"
	SpanMetadataRootParentId = "x-pydio-span-root-id"
	OperationMetadataId      = "x-pydio-operation-id"
)

Variables

This section is empty.

Functions

func GetConfig

func GetConfig(ctx context.Context) common.ConfigValues

GetConfig returns the config from the context in argument

func GetDAO

func GetDAO(ctx context.Context) dao.DAO

GetDAO returns the dao from the context in argument

func GetOperationID

func GetOperationID(ctx context.Context) (string, string)

GetRequestID returns the session id associated to this context

func GetServiceColor

func GetServiceColor(ctx context.Context) uint64

GetServiceColor returns the service name associated to this context

func GetServiceName

func GetServiceName(ctx context.Context) string

GetServiceName returns the service name associated to this context

func HttpMetaExtractorWrapper

func HttpMetaExtractorWrapper(h http.Handler) http.Handler

HttpMetaExtractorWrapper extracts data from the request and puts it in a context Metadata field.

func HttpRequestInfoToMetadata

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

HttpRequestInfoToMetadata extracts as much HTTP metadata as possible and stores it in the context as metadata.

func HttpSpanHandlerWrapper

func HttpSpanHandlerWrapper(h http.Handler) http.Handler

Extract data from request and put it in context Metadata field

func NewMetricsHttpWrapper

func NewMetricsHttpWrapper(h http.Handler) http.Handler

func NewMetricsWrapper

func NewMetricsWrapper(service micro.Service)

func ScanConfig

func ScanConfig(ctx context.Context, target interface{}) error

GetConfig already unmarshalled in a specific format

func SpanClientWrapper

func SpanClientWrapper(c client.Client) client.Client

func SpanHandlerWrapper

func SpanHandlerWrapper(fn server.HandlerFunc) server.HandlerFunc

func SpanSubscriberWrapper

func SpanSubscriberWrapper(subscriberFunc server.SubscriberFunc) server.SubscriberFunc

NewDAOSubscriberWrapper wraps a db connection for each subscriber

func WithConfig

func WithConfig(ctx context.Context, config common.ConfigValues) context.Context

WithConfig links a config to the context

func WithDAO

func WithDAO(ctx context.Context, dao dao.DAO) context.Context

WithDAO links a dao to the context

func WithOperationID

func WithOperationID(ctx context.Context, operationID string, operationLabel ...string) context.Context

WithSessionID returns a context which knows its session ID

func WithServiceColor

func WithServiceColor(ctx context.Context, color ...uint64) context.Context

WithServiceColor returns a context which knows its service assigned color

func WithServiceName

func WithServiceName(ctx context.Context, serviceName string) context.Context

WithServiceName returns a context which knows its service name

func WithSpan

func WithSpan(ctx context.Context, s *Span) context.Context

Types

type Span

type Span struct {
	SpanId       string
	ParentId     string
	RootParentId string
}

func NewSpan

func NewSpan() *Span

func NewSpanFromParent

func NewSpanFromParent(s *Span) *Span

func SpanFromContext

func SpanFromContext(ctx context.Context) (*Span, bool)

func SpanFromHeader

func SpanFromHeader(md metadata.Metadata) (*Span, bool)

Jump to

Keyboard shortcuts

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