xcontext

package
v0.0.0-...-5a98790 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package xcontext helps managing context.Context with timeout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustHandleError

func MustHandleError(ctx context.Context, previousErr error) error

MustHandleError checks if there is an error in the given Context.

If no error, returns the previous error.

If context.DeadlineExceeded, wraps the previous error inside an xerror.Error with xerror.TimeoutCode.

Otherwise wraps the previous error inside an xerror.Error.

It panics if no previous error.

func WithTimeout

func WithTimeout(logger xlog.Logger, seconds float64) (context.Context, context.CancelFunc)

WithTimeout creates a context.Context which times out after given seconds.

Types

This section is empty.

Jump to

Keyboard shortcuts

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