context

package
v2.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package context contains functions to embed data in a context.

There are a few values that we embed in the context that are used, for example, in the log output. This package contains the functions to embed that data in the context, as well as functions to get the data out again and two utility functions to create a logger with the flags already set, and a function to send errors to Sentry with the same flags set.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureError

func CaptureError(ctx context.Context, err error)

CaptureError takes an error and captures the details about it and sends it off to Sentry, if Sentry has been set up.

func ComponentFromContext

func ComponentFromContext(ctx context.Context) (string, bool)

ComponentFromContext returns the component name stored in the context with FromComponent. If no component name was stored in the context, the second argument is false. Otherwise it is true.

func FromComponent

func FromComponent(ctx context.Context, component string) context.Context

FromComponent generates a new context with the given context as its parent and stores the given component name with the context. The component name can be retrieved again using ComponentFromContext.

func FromJobID

func FromJobID(ctx context.Context, jobID uint64) context.Context

FromJobID generates a new context with the given context as its parent and stores the given job ID with the context. The job ID can be retrieved again using JobIDFromContext.

func FromProcessor

func FromProcessor(ctx context.Context, processor string) context.Context

FromProcessor generates a new context with the given context as its parent and stores the given processor ID with the context. The processor ID can be retrieved again using ProcessorFromContext.

func FromRepository

func FromRepository(ctx context.Context, repository string) context.Context

FromRepository generates a new context with the given context as its parent and stores the given repository name with the context. The repository name can be retrieved again using RepositoryFromContext.

func FromUUID

func FromUUID(ctx context.Context, uuid string) context.Context

FromUUID generates a new context with the given context as its parent and stores the given UUID with the context. The UUID can be retrieved again using UUIDFromContext.

func JobIDFromContext

func JobIDFromContext(ctx context.Context) (uint64, bool)

JobIDFromContext returns the job ID stored in the context with FromJobID. If no job ID was stored in the context, the second argument is false. Otherwise it is true.

func LoggerFromContext

func LoggerFromContext(ctx context.Context) *logrus.Entry

LoggerFromContext returns a logrus.Entry with the PID of the current process set as a field, and also includes every field set using the From* functions this package.

func ProcessorFromContext

func ProcessorFromContext(ctx context.Context) (string, bool)

ProcessorFromContext returns the processor name stored in the context with FromProcessor. If no processor name was stored in the context, the second argument is false. Otherwise it is true.

func RepositoryFromContext

func RepositoryFromContext(ctx context.Context) (string, bool)

RepositoryFromContext returns the repository name stored in the context with FromRepository. If no repository name was stored in the context, the second argument is false. Otherwise it is true.

func UUIDFromContext

func UUIDFromContext(ctx context.Context) (string, bool)

UUIDFromContext returns the UUID stored in the context with FromUUID. If no UUID was stored in the context, the second argument is false. Otherwise it is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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