context

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 4 Imported by: 15

Documentation

Overview

Package context holds the last resort overrides and fyi objects that can be passed to clients and transports added to context.Context objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodingFrom

func EncodingFrom(ctx context.Context) string

EncodingFrom looks in the given context and returns `target` as a parsed url if found and valid, otherwise nil.

func LoggerFrom

func LoggerFrom(ctx context.Context) *zap.SugaredLogger

LoggerFrom returns the logger stored in context.

func TargetFrom

func TargetFrom(ctx context.Context) *url.URL

TargetFrom looks in the given context and returns `target` as a parsed url if found and valid, otherwise nil.

func TopicFrom added in v0.9.0

func TopicFrom(ctx context.Context) string

TopicFrom looks in the given context and returns `topic` as a string if found and valid, otherwise "".

func WithEncoding

func WithEncoding(ctx context.Context, encoding string) context.Context

WithEncoding returns back a new context with the given encoding. Encoding is intended to be transport dependent. For http transport, `encoding` should be one of [binary, structured] and will be used to override the outbound codec encoding setting. If the transport does not understand the encoding, it will be ignored.

func WithLogger

func WithLogger(ctx context.Context, logger *zap.SugaredLogger) context.Context

WithLogger returns a new context with the logger injected into the given context.

func WithTarget

func WithTarget(ctx context.Context, target string) context.Context

WithTarget returns back a new context with the given target. Target is intended to be transport dependent. For http transport, `target` should be a full URL and will be injected into the outbound http request.

func WithTopic added in v0.9.0

func WithTopic(ctx context.Context, topic string) context.Context

WithTopic returns back a new context with the given topic. Topic is intended to be transport dependent. For pubsub transport, `topic` should be a Pub/Sub Topic ID.

Types

This section is empty.

Jump to

Keyboard shortcuts

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