MCPcopy
hub / github.com/grafana/dskit / NewTimeoutMiddleware

Function NewTimeoutMiddleware

middleware/http_timeout.go:27–34  ·  view source on GitHub ↗

NewTimeoutMiddleware returns a new timeout middleware that returns a 503 Service Unavailable using the http.TimeoutHandler. Note also that the middleware disables the http server write timeout to ensure the two timeouts don't conflict. We disable the server write timeout b/c it's behavior may be uni

(dt time.Duration, msg string, log log.Logger)

Source from the content-addressed store, hash-verified

25// - returns a 503 Service Unavailable with the provided message
26// - buffers response in memory which may be undesirable for large responses
27func NewTimeoutMiddleware(dt time.Duration, msg string, log log.Logger) Func {
28 return func(next http.Handler) http.Handler {
29 return &timeoutHandler{
30 log: log,
31 handler: http.TimeoutHandler(next, dt, msg),
32 }
33 }
34}
35
36type timeoutHandler struct {
37 log log.Logger

Callers 1

TestTimeoutMiddlewareFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestTimeoutMiddlewareFunction · 0.68