armadacontext

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 4 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
	// contains filtered or unexported fields
}

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 Converts a context.Context to an armadacontext.Context

func New

func New(ctx context.Context, log *logging.Logger) *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 any) *Context

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

func WithLogFields

func WithLogFields(parent *Context, fields map[string]any) *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()

func (*Context) Debug added in v0.16.2

func (ctx *Context) Debug(msg string)

Debug logs a message at level Debug

func (*Context) Debugf added in v0.16.2

func (ctx *Context) Debugf(format string, args ...interface{})

Debugf logs a message at level Debug.

func (*Context) Error added in v0.16.2

func (ctx *Context) Error(msg string)

Error logs a message at level Error

func (*Context) Errorf added in v0.16.2

func (ctx *Context) Errorf(format string, args ...interface{})

Errorf logs a message at level Error.

func (*Context) Fatal added in v0.16.2

func (ctx *Context) Fatal(msg string)

Fatal logs a message at level Fatal then the process will exit with status set to 1.

func (*Context) Fatalf added in v0.16.2

func (ctx *Context) Fatalf(format string, args ...interface{})

Fatalf logs a message at level Fatal.

func (*Context) Info added in v0.16.2

func (ctx *Context) Info(msg string)

Info logs a message at level Info

func (*Context) Infof added in v0.16.2

func (ctx *Context) Infof(format string, args ...interface{})

Infof logs a message at level Info.

func (*Context) Logger added in v0.16.2

func (ctx *Context) Logger() *logging.Logger

func (*Context) Panic added in v0.16.2

func (ctx *Context) Panic(msg string)

Panic logs a message at level Panic

func (*Context) Warn added in v0.16.2

func (ctx *Context) Warn(msg string)

Warn logs a message at level Warn

func (*Context) Warnf added in v0.16.2

func (ctx *Context) Warnf(format string, args ...interface{})

Warnf logs a message at level Warn.

Jump to

Keyboard shortcuts

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