context

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cancel added in v0.9.0

func Cancel(ctx gocontext.Context)

Cancels the context if a CancelFunc is stored in the context.

func CheckContext

func CheckContext(ctx gocontext.Context) error

CheckContext checks if a go context is still active or done When it's done, returns a generic error

func myFunc(ctx context.Context) error {
  if err := common.CheckContext(ctx); err != nil {
  	 return err
  } else {
    doSomething()
  }
}

func New added in v0.9.0

func New(opts ...option) gocontext.Context

New creates a new golang context with the provided options. If a parent context is provided, creates a copy of the parent with further options. If a timeout option is provided, creates a context that cancels itself automatically after the timeout.

func WithParent added in v0.9.0

func WithParent(parent gocontext.Context) option

WithParent returns an option to create a new context based on an existing parent context.

func WithTimeout added in v0.9.0

func WithTimeout(timeout time.Duration) option

WithTimeout return an option to create a new context that cancels itself automatically after the timeout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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