xcontext

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package xcontext provides Context with custom errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContextTimeout

func GetContextTimeout(ctx context.Context) (time.Duration, error)

GetContextTimeout returns the duration set on the Context for its Timeout If the Timeout has not been set, then -1 is returned

Types

type CancelFunc

type CancelFunc func(err error)

CancelFunc is a function to cancel an associated context with a specified error. If a context is already canceled, calling this function has no effect. It panics if err is nil. Upon returning from this function, an associated context is guaranteed to be in a canceled state (i.e. Done channel is closed, Err returns non-nil).

func WithCancel

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

WithCancel returns a context that can be canceled with arbitrary errors.

func WithDeadline

func WithDeadline(parent context.Context, t time.Time, err error) (context.Context, CancelFunc)

WithDeadline returns a context that can be canceled with arbitrary errors on reaching a specified deadline. It panics if err is nil.

func WithTimeout

func WithTimeout(parent context.Context, d time.Duration, err error) (context.Context, CancelFunc)

WithTimeout returns a context that can be canceled with arbitrary errors on reaching a specified timeout. It panics if err is nil.

Jump to

Keyboard shortcuts

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