timeout

package
v0.0.0-...-f4cebfc Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTimeoutError

func IsTimeoutError(e error) bool

IsTimeoutError checks if the provided error is a TimeoutError.

func TimeoutAfter

func TimeoutAfter(t time.Duration, errorMsg string, f func(*time.Timer) error) error

TimeoutAfter executes the provided function and returns TimeoutError in the case that the execution time of the function exceeded the provided duration. The provided function is passed the timer in case it wishes to reset it. If so, the following pattern must be used:

if !timer.Stop() {
  return &TimeoutError{}
}

timer.Reset(timeout)

Types

type TimeoutError

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

TimeoutError is error returned after timeout occurred.

func (*TimeoutError) Error

func (t *TimeoutError) Error() string

Error implements the Go error interface.

Jump to

Keyboard shortcuts

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