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
Click to show internal directories.
Click to hide internal directories.