timeoutmiddleware

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c Config) (endpoint.Middleware, error)

New returns a new timeout middleware.

After timeout is reached, if the middleware is configured to wait, it will just cancel the context and wait for next endpoint to return. But if the middleware is configured to not wait, it will run the next endpoint inside a go-routine and return error as soon as the context is canceled.

Types

type Config

type Config struct {
	// Timeout is the duration of the timeout
	Timeout time.Duration

	// Wait indicates if the middleware should wait for
	// the next middleware to finish or it should return an error
	// right away.
	Wait bool

	// ErrorSeverity is the severity of the error when the context
	// is canceled, probably due the timeout.
	ErrorSeverity errors.Severity

	// ErrorCode is the error code when the context is canceled.
	ErrorCode errors.Code
}

Config is the configuration of the timeout middleware.

func NewDefaultConfig

func NewDefaultConfig() Config

Jump to

Keyboard shortcuts

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