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 ¶
- func CaptureError(ctx context.Context, err error)
- func ComponentFromContext(ctx context.Context) (string, bool)
- func FromComponent(ctx context.Context, component string) context.Context
- func FromJWT(ctx context.Context, jwt string) context.Context
- func FromJobID(ctx context.Context, jobID uint64) context.Context
- func FromProcessor(ctx context.Context, processor string) context.Context
- func FromRepository(ctx context.Context, repository string) context.Context
- func FromUUID(ctx context.Context, uuid string) context.Context
- func JWTFromContext(ctx context.Context) (string, bool)
- func JobIDFromContext(ctx context.Context) (uint64, bool)
- func LoggerFromContext(ctx context.Context) *logrus.Entry
- func ProcessorFromContext(ctx context.Context) (string, bool)
- func RepositoryFromContext(ctx context.Context) (string, bool)
- func UUIDFromContext(ctx context.Context) (string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureError ¶
CaptureError takes an error and captures the details about it and sends it off to Sentry, if Sentry has been set up.
func ComponentFromContext ¶
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 ¶
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 FromJWT ¶
FromJWT generates a new context with the given context as its parent and stores the given JWT with the context. The JWT can be retrieved again using JWTFromContext.
func FromJobID ¶
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 ¶
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 ¶
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 ¶
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 JWTFromContext ¶
JWTFromContext returns the jwt stored in the context with FromJWT. If no jwt was stored in the context, the second argument is false. Otherwise it is true.
func JobIDFromContext ¶
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 ¶
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 ¶
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 ¶
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.
Types ¶
This section is empty.