Liking cljdoc? Tell your friends :D

cl4cl.http

The only namespace that touches the network. Sends request maps with java.net.http and retries failures according to a policy map.

The only namespace that touches the network. Sends request maps with
java.net.http and retries failures according to a policy map.
raw docstring

backoff-msclj

(backoff-ms {:keys [base-ms cap-ms max-retry-after-ms]
             :or {max-retry-after-ms 60000}}
            attempt
            e
            jitter)

How long to wait before retry number attempt (from 1): the server's retry-after if it sent one of at most :max-retry-after-ms (default 60000), else exponential backoff from :base-ms, capped at :cap-ms, scaled by jitter, a number in [0, 1). A longer retry-after is ignored rather than obeyed, so a response cannot park the caller for hours.

How long to wait before retry number attempt (from 1): the server's
retry-after if it sent one of at most :max-retry-after-ms (default
60000), else exponential backoff from :base-ms, capped at :cap-ms,
scaled by jitter, a number in [0, 1). A longer retry-after is ignored
rather than obeyed, so a response cannot park the caller for hours.
sourceraw docstring

http-clientclj

(http-client {:keys [connect-timeout-ms]})

A java.net.http client. One instance is meant to be shared.

A java.net.http client. One instance is meant to be shared.
sourceraw docstring

idle-timeoutclj

(idle-timeout body timeout-ms)

Wrap an open response body so that a read which waits more than timeout-ms for data throws an HttpTimeoutException, where the JDK's stream would block for as long as the peer stays silent. Only the wait for data is timed, so a caller that is slow to come back for more is not idle. Closing the result closes the body.

Wrap an open response body so that a read which waits more than
timeout-ms for data throws an HttpTimeoutException, where the JDK's
stream would block for as long as the peer stays silent. Only the wait
for data is timed, so a caller that is slow to come back for more is
not idle. Closing the result closes the body.
sourceraw docstring

send!clj

(send! http-client {:keys [idle-timeout-ms] :as request} as)

Send a request map {:method :url :headers :body :timeout-ms} and return {:status :headers :body}. :body is a string, or an open InputStream when as is :stream; the caller must then close it. A request that gets no response throws a :cl4cl.error/connection ex-info.

A :stream request may hold :idle-timeout-ms, the longest wait for the response to start and then for each further part of the body, as idle-timeout describes. It should not hold :timeout-ms, which on newer JDKs limits the whole body.

Send a request map {:method :url :headers :body :timeout-ms} and return
{:status :headers :body}. :body is a string, or an open InputStream when
as is :stream; the caller must then close it. A request that gets no
response throws a :cl4cl.error/connection ex-info.

A :stream request may hold :idle-timeout-ms, the longest wait for the
response to start and then for each further part of the body, as
`idle-timeout` describes. It should not hold :timeout-ms, which on newer
JDKs limits the whole body.
sourceraw docstring

with-retryclj

(with-retry {:keys [max sleep]
             :or {sleep (fn* [p1__2052#] (Thread/sleep (long p1__2052#)))}
             :as policy}
            f)

Call the thunk f, retrying while it throws a retryable cl4cl error, up to :max extra attempts. :sleep, a function of milliseconds, is optional and exists so tests need not wait.

Call the thunk f, retrying while it throws a retryable cl4cl error, up
to :max extra attempts. :sleep, a function of milliseconds, is optional
and exists so tests need not wait.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close