Normalized provider limits surface.
Providers may optionally expose :provider/limits-fn in the global
registry. The function returns provider-specific limit/quota data;
this namespace wraps it in one validated envelope and augments it
with static provider metadata from svar's catalog (currently RPM /
TPM).
The limits vocabulary and the report shape belong to
com.blockether.vis.contract.provider; what stays here is fetching, caching and
normalizing whatever a provider answered.
Goals:
Normalized provider limits surface. Providers may optionally expose `:provider/limits-fn` in the global registry. The function returns provider-specific limit/quota data; this namespace wraps it in one validated envelope and augments it with static provider metadata from svar's catalog (currently RPM / TPM). The limits vocabulary and the report shape belong to `com.blockether.vis.contract.provider`; what stays here is fetching, caching and normalizing whatever a provider answered. Goals: - one host-level shape for all providers, - explicit support for providers that only know static limits, - contract validation of every returned report, - graceful error envelopes instead of exploding the caller when a provider-specific implementation is absent or malformed.
(all-provider-limits)Return normalized limits reports for every registered provider in registration order.
Return normalized limits reports for every registered provider in registration order.
(consume-reset-credit! provider-id
{:keys [account-id idempotency-key] :as attempt})Consume one provider reset after human confirmation. The provider callback
accepts {:account-id string :idempotency-key string} and returns an outcome
(reset, nothing_to_reset, no_credit, already_redeemed) or a sanitized
{:error keyword :message string}. Invalidate limits even on uncertain IO:
a reset may have succeeded before its response was lost.
Consume one provider reset after human confirmation. The provider callback
accepts `{:account-id string :idempotency-key string}` and returns an outcome
(`reset`, `nothing_to_reset`, `no_credit`, `already_redeemed`) or a sanitized
`{:error keyword :message string}`. Invalidate limits even on uncertain IO:
a reset may have succeeded before its response was lost.(flush-limits-cache!)(flush-limits-cache! provider-id)Drop cached limits reports so the next read hits the provider again.
Called after auth changes (sign-in / sign-out): the cached report for a
provider that just re-authenticated would otherwise keep saying
:unauthenticated until its budget ran out.
This is the ONE limits cache. A :provider/limits-fn that kept a cache of
its own would outlive this flush and keep painting the pre-login verdict at a
credential that already works, so a limits fn FETCHES and nothing else.
Drop cached limits reports so the next read hits the provider again. Called after auth changes (sign-in / sign-out): the cached report for a provider that just re-authenticated would otherwise keep saying `:unauthenticated` until its budget ran out. This is the ONE limits cache. A `:provider/limits-fn` that kept a cache of its own would outlive this flush and keep painting the pre-login verdict at a credential that already works, so a limits fn FETCHES and nothing else.
(provider-limits provider-id)Return a normalized, contract-validated limits report for one provider id.
The provider's optional :provider/limits-fn supplies the dynamic
portion. This host wrapper backfills static svar metadata and always
returns a valid contract-provider/report envelope, even when the
provider-specific implementation is absent, missing, throws, or returns
malformed data.
Providers that only have static svar catalog metadata still return a
usable :ok report so callers can surface RPM / TPM without needing a
registered runtime extension.
Return a normalized, contract-validated limits report for one provider id. The provider's optional `:provider/limits-fn` supplies the dynamic portion. This host wrapper backfills static svar metadata and always returns a valid `contract-provider/report` envelope, even when the provider-specific implementation is absent, missing, throws, or returns malformed data. Providers that only have static svar catalog metadata still return a usable `:ok` report so callers can surface RPM / TPM without needing a registered runtime extension.
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 |