middleware

package
v0.33.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLogger

func WithLogger(log logr.Logger) func(http.Handler) http.Handler

func WithStreamDeadline added in v0.5.0

func WithStreamDeadline(writeTimeout, streamStallTimeout time.Duration) func(http.Handler) http.Handler

WithStreamDeadline adjusts the PER-REQUEST write deadline so a streaming response is not severed by the connection-level http.Server.WriteTimeout.

In Go, WriteTimeout deadlines the whole connection rather than a single slow write, so an in-flight text/event-stream response is torn down mid-body when it elapses — no matter how healthily it is flushing. That is kdex-tech/host-manager#167: both production SSE surfaces sat in a permanent ~60s reconnect loop.

A writeTimeout of zero or less means the server has no write deadline, so there is nothing to adjust and this is a pass-through.

streamStallTimeout is the SEPARATE, much larger window an SSE response slides on. SSE is not exempt from bounding — it is bounded on its own terms. Clearing the deadline outright (the first #167 implementation) left a consumer that stops reading parked in Flush->conn.Write under TCP backpressure with nothing to cut it: the request context cancels on close, not on a stalled reader, so Linux TCP keepalive reaped it at ~2h11m where pre-#167 it died at writeTimeout. Nothing else in the repo covers that — ReadTimeout/ReadHeaderTimeout bound the request only, IdleTimeout bounds inter-request idle only, and there is no ConnState/LimitListener/TimeoutHandler — and each held connection pins a goroutine, an FD, the upstream connection and ReverseProxy's 32KB buffer. The design's rationale ("the cadence belongs to the backend") argues against a CADENCE-SIZED cap, not against any cap: at the 5m default a healthy stream runs unbounded at 20x the 15s keep-alive cadence of the affected backends, while a stalled one dies in minutes. Zero or less restores the cleared-deadline behavior for SSE, which is the documented escape hatch for a backend whose legitimate silence can exceed any window.

Types

This section is empty.

Jump to

Keyboard shortcuts

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