appcontext

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package appcontext implements the app context. The context includes various utilities such as the logger used through the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context is the application context that carries a context.Context and some other utilities to be used across the application.

Implements context.Context.

func Background

func Background() *Context

Background returns an empty context with default logrus logger.

func BackgroundDebug

func BackgroundDebug() *Context

BackgroundDebug is same as Background with Debug returning true.

func WithCancel

func WithCancel(parent *Context) (ctx *Context, cancel func())

WithCancel creates a Context from context.Context with a cancel function.

func WithSignals

func WithSignals(parent *Context, signals ...os.Signal) (ctx *Context, cancel func())

WithSignals creates a context that cancels on receiving the os.Signal.

func (*Context) Deadline

func (c *Context) Deadline() (deadline time.Time, ok bool)

Deadline returns the time when work done on behalf of this context should be canceled.

func (*Context) Debug

func (c *Context) Debug() bool

Debug tells if the application is running in debugging mode or not. This is set by setting the `DEBUG` environment variable to "on".

func (*Context) Done

func (c *Context) Done() <-chan struct{}

Done returns a channel that's closed when work done on behalf of this context should be canceled.

func (*Context) Err

func (c *Context) Err() error

Err returns the error from the context.

func (*Context) Logger

func (c *Context) Logger() *logrus.Logger

Logger returns the logger from context.

func (*Context) Value

func (c *Context) Value(key interface{}) interface{}

Value returns the value associated with this context for key, or nil if no value is associated with key.

Jump to

Keyboard shortcuts

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