ETS-backed registry for multi-tenant Plaid configurations.
Stores per-tenant PlaidEx.Config structs for runtime lookup.
Supports secret rotation without application restart.
Usage
# Register a tenant at runtime (e.g., when a user connects Plaid)
PlaidEx.Config.TenantRegistry.register("acme_corp",
PlaidEx.Config.new!(
client_id: vault.get("acme/plaid/client_id"),
secret: vault.get("acme/plaid/secret"),
environment: :production,
tenant_id: "acme_corp"
)
)
# Retrieve tenant config for an API call
{:ok, config} = PlaidEx.Config.TenantRegistry.get("acme_corp")
# Rotate a secret without full re-registration
PlaidEx.Config.TenantRegistry.update_secret("acme_corp", new_secret)
# Remove a tenant (e.g., when they unsubscribe)
PlaidEx.Config.TenantRegistry.deregister("acme_corp")
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the number of registered tenants.
Removes a tenant from the registry.
Retrieves a tenant's configuration.
Retrieves a tenant config or raises if not found. Useful in pipelines where a missing tenant is a programming error.
Lists all registered tenant IDs.
Registers or updates a tenant configuration.
Rotates the secret for a tenant without full re-registration.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec count() :: non_neg_integer()
Returns the number of registered tenants.
@spec deregister(String.t()) :: :ok
Removes a tenant from the registry.
@spec get(String.t()) :: {:ok, PlaidEx.Config.t()} | :not_found
Retrieves a tenant's configuration.
@spec get!(String.t()) :: PlaidEx.Config.t()
Retrieves a tenant config or raises if not found. Useful in pipelines where a missing tenant is a programming error.
@spec list_tenants() :: [String.t()]
Lists all registered tenant IDs.
@spec register(String.t(), PlaidEx.Config.t()) :: :ok
Registers or updates a tenant configuration.
@spec start_link(keyword()) :: GenServer.on_start()
Rotates the secret for a tenant without full re-registration.