livery_stripe_client (livery_stripe v0.1.0)
View SourceLow-level Stripe request pipeline over livery_client.
build/1 turns a config map into a livery_client value wired with the
full resilience stack (timeout, retry with backoff, circuit breaker, and a
concurrency gate). Build it once and cache/1 it in persistent_term so
the breaker and gate state is shared across all callers.
do_request/4,5 is the single entry every domain module funnels through:
it form-encodes parameters, attaches an Idempotency-Key on mutating
requests (so a retried POST is deduplicated by Stripe rather than charged
twice), runs the call, and maps the response to {ok, map()} or an error.
Errors are one of:
{stripe_error, Status, ErrorMap}- Stripe returned a non-2xx with a JSONerrorobject,{decode, Body}- a 2xx body that was not valid JSON,- any
livery_clientstack error as a value:timeout,circuit_open,overloaded, or a transport reason from the adapter.
Summary
Types
Functions
-spec build(config()) -> livery_client:client().
Build a Stripe livery_client from a config map.
-spec cache(livery_client:client()) -> ok.
Cache a built client for cached/0 (shared, process-independent).
-spec cached() -> livery_client:client().
Fetch the cached client, or raise if none was configured.
-spec decode(livery_client:response()) -> result().
Map a livery_client response to {ok, map()} or a Stripe error.
-spec do_request(livery_client:client(), method(), binary(), params()) -> result().
-spec has_client() -> boolean().
Whether a client has been cached.