ctxutil

package
v0.0.0-...-d046166 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package ctxutil provides convenience functions for working with context.Context objects.

Index

Constants

View Source
const MaxTimeout time.Duration = math.MaxInt64

MaxTimeout is the maximum value of time.Duration, approximately 290 years.

This value might be useful on calling some timeout-related functions. For example, context.WithTimeout(ctx, ctxutil.MaxTimeout) returns a new context with effectively the same deadline as the original context. (Precisely, if the original context has no deadline or a deadline later than MaxDuration, the new deadline is different, but it is so future that we do not need to distinguish them.)

Variables

This section is empty.

Functions

func DeadlineBefore

func DeadlineBefore(ctx context.Context, t time.Time) bool

DeadlineBefore returns true if ctx has a deadline that expires before t. It returns true if the deadline has already expired and false if no deadline is set.

func Shorten

Shorten returns a context and cancel function derived from ctx with its deadline shortened by d. If ctx has no deadline, the returned context won't have one either. Note that if ctx's deadline is less than d in the future, the returned context's deadline will have already expired.

Types

This section is empty.

Jump to

Keyboard shortcuts

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