livery_s3_credentials_store (livery_s3 v0.1.0)

View Source

Cache for refreshing credential providers.

A gen_server owns a public ETS table keyed by provider key, holding the last fetched creds(). current/2 serves cached credentials directly (no process round-trip) and only routes through the server to (re)fetch when the entry is missing or within the refresh margin of expires_at (default 300 s). Fetches are single-flighted by the server, so a thundering herd of expired reads triggers one refresh. Started by the livery_s3 application; only refreshing providers (imds, web-identity, custom funs) need it.

Summary

Functions

Return cached credentials for Key, refreshing via Provider if stale.

Types

state()

-type state() :: #state{}.

Functions

current(Key, Provider)

-spec current(term(), livery_s3_credentials:provider()) ->
                 {ok, livery_s3_credentials:creds()} | {error, term()}.

Return cached credentials for Key, refreshing via Provider if stale.

handle_call/3

-spec handle_call(term(), {pid(), term()}, state()) ->
                     {reply, {ok, livery_s3_credentials:creds()} | {error, term()}, state()}.

handle_cast(Msg, State)

-spec handle_cast(term(), state()) -> {noreply, state()}.

handle_info(Info, State)

-spec handle_info(term(), state()) -> {noreply, state()}.

init/1

-spec init([]) -> {ok, state()}.

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.