fast-twitch.middlewares.timeout
Complete generated reference for fast-twitch.middlewares.timeout
Usage and execution boundary
Bounds Promise/callback response creation, with late discarded-body cleanup. It does not preempt synchronous work, cancel arbitrary upstream jobs or bound a stream that has already been returned.
(ns application.middleware
(:require [fast-twitch.middlewares.timeout :as middleware]))
(defn handler [_]
{:status 200 :headers {"content-type" "text/plain"} :body "Hello"})
(def app (middleware/wrap-timeout handler {:timeout-ms 5000}))
This defines the Ring handler portion. Adapt app through routing/ft-handler or pass it to server/listen!; startup instructions and a complete walkthrough show the surrounding project.
Settings and defaults
| Setting | Meaning |
|---|---|
:timeout-ms / :ms |
Default 30000 |
:error-response |
Default 503 timeout response |
:error-handler |
Function [request] |
Wrapper order and all middleware families. The function reference below preserves the upstream signatures and source links; helper functions do not all share the wrapper's arity.
Upstream function reference
Bounds asynchronous handler execution time with a timeout response.
default-timeout-ms
The default timeout in milliseconds. Source
default-timeout-response
The default response returned when a handler exceeds the configured timeout. Source
timeout-promise
(timeout-promise request timeout-ms options)
Function.
Returns a promise that resolves to a timeout response after timeout-ms. Source
timeout-response
(timeout-response request options)
Function.
Builds the response returned when a request times out. Source
wrap-timeout
(wrap-timeout handler)
(wrap-timeout handler options)
Function.
Wraps a handler so promise or callback responses are bounded by a timeout. Source