armadacontext

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	context.Context
	logrus.FieldLogger
}

Context is an extension of Go's context which also includes a logger. This allows us to pass round a contextual logger while retaining type-safety

func Background

func Background() *Context

Background creates an empty context with a default logger. It is analogous to context.Background()

func ErrGroup

func ErrGroup(ctx *Context) (*errgroup.Group, *Context)

ErrGroup returns a new Error Group and an associated Context derived from ctx. It is analogous to errgroup.WithContext(ctx)

func FromGrpcCtx

func FromGrpcCtx(ctx context.Context) *Context

FromGrpcCtx creates a context where the logger is extracted via ctxlogrus's Extract() method. Note that this will result in a no-op logger if a logger hasn't already been inserted into the context via ctxlogrus

func New

func New(ctx context.Context, log *logrus.Entry) *Context

New returns an armada context that encapsulates both a go context and a logger

func TODO

func TODO() *Context

TODO creates an empty context with a default logger. It is analogous to context.TODO()

func WithCancel

func WithCancel(parent *Context) (*Context, context.CancelFunc)

WithCancel returns a copy of parent with a new Done channel. It is analogous to context.WithCancel()

func WithDeadline

func WithDeadline(parent *Context, d time.Time) (*Context, context.CancelFunc)

WithDeadline returns a copy of the parent context with the deadline adjusted to be no later than d. It is analogous to context.WithDeadline()

func WithLogField

func WithLogField(parent *Context, key string, val interface{}) *Context

WithLogField returns a copy of parent with the supplied key-value added to the logger

func WithLogFields

func WithLogFields(parent *Context, fields logrus.Fields) *Context

WithLogFields returns a copy of parent with the supplied key-values added to the logger

func WithTimeout

func WithTimeout(parent *Context, timeout time.Duration) (*Context, context.CancelFunc)

WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). It is analogous to context.WithTimeout()

func WithValue

func WithValue(parent *Context, key, val any) *Context

WithValue returns a copy of parent in which the value associated with key is val. It is analogous to context.WithValue()

Jump to

Keyboard shortcuts

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