Hash-keyed provision cache. ensure/3 returns a cached provider handle for a given
{provider, spec}, plus the :environment digest and :cache_scope when given, calling
provider.provision/2 only on a miss. The handle is the durable artifact; where the
{hash → handle} mapping lives is pluggable via the ReqManagedAgents.Provisioner.Store
behaviour (:store option) — in-process ETS by default, or a persistent store (e.g.
Store.File) for reuse across OS processes.
Summary
Functions
Returns the cached handle for spec, provisioning it on a miss. The cache key
covers {provider, spec}, the :environment digest when given, and
:cache_scope when given.
Drop any cache entry whose value is handle (called after teardown). With a
persistent store (e.g. Store.File) the handle must be JSON-encodable —
same constraint as ensure/3's store writes; non-encodable values raise.
Functions
@spec ensure(module(), ReqManagedAgents.Provider.spec(), keyword()) :: {:ok, ReqManagedAgents.Provider.handle()} | {:error, term()}
Returns the cached handle for spec, provisioning it on a miss. The cache key
covers {provider, spec}, the :environment digest when given, and
:cache_scope when given.
:cache_scope is an optional non-empty string naming the authority a handle
belongs to, such as the account and endpoint whose credentials provision it,
so the same spec provisioned under two accounts is never shared between them.
Pass a reference rather than a credential, and change it when the authority
changes. Any other value returns {:error, {:invalid_opts, :cache_scope}}
without reading the store or calling the provider.
See ReqManagedAgents.Provisioner.Environments.ensure_environment/3.
@spec evict( ReqManagedAgents.Provider.handle(), keyword() ) :: :ok
Drop any cache entry whose value is handle (called after teardown). With a
persistent store (e.g. Store.File) the handle must be JSON-encodable —
same constraint as ensure/3's store writes; non-encodable values raise.
See ReqManagedAgents.Provisioner.Environments.prune_environments/3.