ttnctx

package
v0.0.0-...-b349366 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 4 Imported by: 63

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoToken = errors.New("context: Metadata does not contain token")
	ErrNoKey   = errors.New("context: Metadata does not contain key")
	ErrNoID    = errors.New("context: Metadata does not contain id")
)

Errors that are returned when an item could not be retrieved TODO: use go-utils/errors when ready

Functions

func IDFromIncomingContext

func IDFromIncomingContext(ctx context.Context) (string, error)

IDFromIncomingContext gets the key from the incoming context or returns ErrNoID

func IDFromMetadata

func IDFromMetadata(md metadata.MD) (string, error)

IDFromMetadata gets the key from the metadata or returns ErrNoID

func KeyFromIncomingContext

func KeyFromIncomingContext(ctx context.Context) (string, error)

KeyFromIncomingContext gets the key from the incoming context or returns ErrNoKey

func KeyFromMetadata

func KeyFromMetadata(md metadata.MD) (string, error)

KeyFromMetadata gets the key from the metadata or returns ErrNoKey

func LimitAndOffsetFromIncomingContext

func LimitAndOffsetFromIncomingContext(ctx context.Context) (limit, offset uint64, err error)

LimitAndOffsetFromIncomingContext gets the limit and offset from the incoming context

func LimitFromMetadata

func LimitFromMetadata(md metadata.MD) (uint64, error)

LimitFromMetadata gets the limit from the metadata

func MetadataFromIncomingContext

func MetadataFromIncomingContext(ctx context.Context) metadata.MD

MetadataFromIncomingContext gets the metadata from the given context

func MetadataFromOutgoingContext

func MetadataFromOutgoingContext(ctx context.Context) metadata.MD

MetadataFromOutgoingContext gets the metadata from the given context

func OffsetFromMetadata

func OffsetFromMetadata(md metadata.MD) (uint64, error)

OffsetFromMetadata gets the offset from the metadata

func OutgoingContextWithID

func OutgoingContextWithID(ctx context.Context, id string) context.Context

OutgoingContextWithID returns an outgoing context with the id

func OutgoingContextWithKey

func OutgoingContextWithKey(ctx context.Context, key string) context.Context

OutgoingContextWithKey returns an outgoing context with the key

func OutgoingContextWithLimitAndOffset

func OutgoingContextWithLimitAndOffset(ctx context.Context, limit, offset uint64) context.Context

OutgoingContextWithLimitAndOffset returns an outgoing context with the limit and offset

func OutgoingContextWithServiceInfo

func OutgoingContextWithServiceInfo(ctx context.Context, serviceName, serviceVersion, netAddress string) context.Context

OutgoingContextWithServiceInfo returns an outgoing context with the id

func OutgoingContextWithToken

func OutgoingContextWithToken(ctx context.Context, token string) context.Context

OutgoingContextWithToken returns an outgoing context with the token

func ServiceInfoFromIncomingContext

func ServiceInfoFromIncomingContext(ctx context.Context) (serviceName, serviceVersion, netAddress string, err error)

ServiceInfoFromIncomingContext gets the service information from the incoming context or returns empty strings

func ServiceInfoFromMetadata

func ServiceInfoFromMetadata(md metadata.MD) (serviceName, serviceVersion, netAddress string, err error)

ServiceInfoFromMetadata gets the service information from the metadata or returns empty strings

func TokenFromIncomingContext

func TokenFromIncomingContext(ctx context.Context) (string, error)

TokenFromIncomingContext gets the token from the incoming context or returns ErrNoToken

func TokenFromMetadata

func TokenFromMetadata(md metadata.MD) (string, error)

TokenFromMetadata gets the token from the metadata or returns ErrNoToken

Types

This section is empty.

Jump to

Keyboard shortcuts

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