The claim-check gateway client: fetch the bytes a claim ref names and verify them against the digest the queue message carries.
(def gateway (claim-check/client "http://localhost:4004"))
(claim-check/redeem gateway (:claim message) (:sha256 message))
The gateway never checks the digest itself, so redeem always does: the
reader's own end-to-end check, run before the bytes are returned.
Failures are ex-infos; see ankusa.sdk.errors for the types and the
:retryable bit. Every call is one request: no retry, no followed redirect.
The claim-check gateway client: fetch the bytes a claim ref names and verify them against the digest the queue message carries. ```clojure (def gateway (claim-check/client "http://localhost:4004")) (claim-check/redeem gateway (:claim message) (:sha256 message)) ``` The gateway never checks the digest itself, so `redeem` always does: the reader's own end-to-end check, run before the bytes are returned. Failures are `ex-info`s; see `ankusa.sdk.errors` for the types and the `:retryable` bit. Every call is one request: no retry, no followed redirect.
(client base-url)(client base-url opts)Build a client for the gateway at base-url (an absolute http(s) URL).
opts may hold:
:headers: a map of header name (string or keyword) to string value,
sent on every request.:timeout-ms: a positive integer, default 10000. It bounds the whole
call, from connecting through the last body byte.:transport: a function that performs one request, to replace the JDK
HTTP client (a different HTTP library, an in-process fake). It receives
{:method "GET" :url "http://host/path?q" :headers {"name" "value"} :body <byte[] or nil> :timeout-ms 10000} and returns
{:status 200 :headers {...} :body <byte[] or nil>}. Throwing any
Exception is a transport failure. It must not follow redirects.Bad input throws IllegalArgumentException.
Build a client for the gateway at `base-url` (an absolute http(s) URL).
`opts` may hold:
* `:headers`: a map of header name (string or keyword) to string value,
sent on every request.
* `:timeout-ms`: a positive integer, default `10000`. It bounds the whole
call, from connecting through the last body byte.
* `:transport`: a function that performs one request, to replace the JDK
HTTP client (a different HTTP library, an in-process fake). It receives
`{:method "GET" :url "http://host/path?q" :headers {"name" "value"}
:body <byte[] or nil> :timeout-ms 10000}` and returns
`{:status 200 :headers {...} :body <byte[] or nil>}`. Throwing any
`Exception` is a transport failure. It must not follow redirects.
Bad input throws `IllegalArgumentException`.(health client)Liveness probe: GET /health. A 200 with a JSON body returns it decoded
(keyword keys); anything else, including a 200 with a body that is not
JSON, throws :ankusa.sdk/ClaimCheckUnavailableError.
Liveness probe: `GET /health`. A `200` with a JSON body returns it decoded (keyword keys); anything else, including a `200` with a body that is not JSON, throws `:ankusa.sdk/ClaimCheckUnavailableError`.
(redeem client ref sha256)Fetch the bytes ref names and return them as a byte[], after checking
that their SHA-256 is sha256 (64 lowercase hex characters).
Nothing is requested when ref or sha256 is malformed
(:ankusa.sdk/InvalidClaimRefError). Otherwise: ClaimNotFoundError on a
404, ClaimRejectedError on any other 4xx but 408 and 429,
ClaimIntegrityError when the digest differs, and
ClaimCheckUnavailableError (retryable) for a 408, a 429 (a front layer
throttling or timing out), any other status, or an unreachable gateway.
Fetch the bytes `ref` names and return them as a `byte[]`, after checking that their SHA-256 is `sha256` (64 lowercase hex characters). Nothing is requested when `ref` or `sha256` is malformed (`:ankusa.sdk/InvalidClaimRefError`). Otherwise: `ClaimNotFoundError` on a `404`, `ClaimRejectedError` on any other `4xx` but `408` and `429`, `ClaimIntegrityError` when the digest differs, and `ClaimCheckUnavailableError` (retryable) for a `408`, a `429` (a front layer throttling or timing out), any other status, or an unreachable gateway.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |