propagation

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package propagation contains interface definition for HTTP propagators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHTTP added in v0.2.2

func ExtractHTTP(ctx context.Context, props Propagators, supplier HTTPSupplier) context.Context

ExtractHTTP applies props.HTTPExtractors() to the passed context and the supplier and returns the combined result context.

func InjectHTTP added in v0.2.2

func InjectHTTP(ctx context.Context, props Propagators, supplier HTTPSupplier)

InjectHTTP applies props.HTTPInjectors() to the passed context and the supplier.

Types

type Config added in v0.2.2

type Config struct {
	// contains filtered or unexported fields
}

Config contains the current set of extractors and injectors.

type HTTPExtractor added in v0.2.2

type HTTPExtractor interface {
	// Extract method retrieves encoded information using supplier
	// from the associated carrier, decodes it and creates a new
	// context containing the decoded information.
	//
	// Information can be a correlation context or a remote span
	// context. In case of span context, the propagator should
	// store it in the context using
	// trace.ContextWithRemoteSpanContext. In case of correlation
	// context, the propagator should use correlation.WithMap to
	// store it in the context.
	Extract(context.Context, HTTPSupplier) context.Context
}

HTTPExtractor extracts information from a HTTPSupplier into a context.

type HTTPInjector added in v0.2.2

type HTTPInjector interface {
	// Inject method retrieves information from the context,
	// encodes it into propagator specific format and then injects
	// the encoded information using supplier into an associated
	// carrier.
	Inject(context.Context, HTTPSupplier)
}

HTTPInjector injects information into a HTTPSupplier.

type HTTPPropagator added in v0.2.2

type HTTPPropagator interface {
	HTTPInjector
	HTTPExtractor

	// GetAllKeys returns the HTTP header names used.
	GetAllKeys() []string
}

HTTPPropagator is the interface to inject to and extract from HTTPSupplier.

type HTTPSupplier added in v0.2.2

type HTTPSupplier interface {
	// Get method retrieves a single value for a given key.
	Get(key string) string
	// Set method stores a single value for a given key. Note that
	// this should not be appending a value to some array, but
	// rather overwrite the old value.
	Set(key string, value string)
}

HTTPSupplier is an interface that specifies methods to retrieve and store a single value for a key to an associated carrier. It is implemented by http.Headers.

type Option added in v0.2.2

type Option func(*Config)

Option support passing configuration parameters to New().

func WithExtractors added in v0.2.2

func WithExtractors(ext ...HTTPExtractor) Option

WithExtractors appends to the optional extractor set.

func WithInjectors added in v0.2.2

func WithInjectors(inj ...HTTPInjector) Option

WithInjectors appends to the optional injector set.

type Propagators added in v0.2.2

type Propagators interface {
	// HTTPExtractors returns the configured extractors.
	HTTPExtractors() []HTTPExtractor

	// HTTPInjectors returns the configured injectors.
	HTTPInjectors() []HTTPInjector
}

Propagators is the interface to a set of injectors and extractors for all supported carrier formats. It can be used to chain multiple propagators into a single entity.

func New added in v0.2.2

func New(options ...Option) Propagators

New returns a standard Propagators implementation.

Jump to

Keyboard shortcuts

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