AshAuthentication. BankID. Expunger
(ash_authentication_bankid v0.1.3)
View Source
GenServer that periodically cleans up expired and consumed BankID orders.
This process prevents the indefinite accumulation of orders in the database by deleting:
- Orders that have exceeded their TTL (expired)
- Consumed orders that are older than the retention period
Configuration
The Expunger is configured through the BankID strategy DSL:
bank_id do
order_resource MyApp.Accounts.BankIDOrder
cleanup_interval 300_000 # 5 minutes in milliseconds
consumed_order_ttl 86_400 # 24 hours in seconds
endConfiguration options:
cleanup_interval: How often to run cleanup (default: 5 minutes)order_ttl: How long orders are valid (inherited from strategy)consumed_order_ttl: How long to retain consumed orders (default: 24 hours)
Usage
The Expunger should be added to your application's supervision tree:
children = [
# ... other children
{AshAuthentication.BankID.Expunger,
order_resource: MyApp.Accounts.BankIDOrder,
order_ttl: 300,
cleanup_interval: 300_000,
consumed_order_ttl: 86_400}
]Manual Cleanup
You can trigger a manual cleanup (useful for testing):
AshAuthentication.BankID.Expunger.trigger_cleanup()
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts the Expunger GenServer.
Manually trigger a cleanup (useful for testing).
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Starts the Expunger GenServer.
Options
:order_resource(required) - The Ash resource module for BankID orders:order_ttl(required) - Order TTL in seconds:cleanup_interval(optional) - Cleanup interval in milliseconds:consumed_order_ttl(optional) - Consumed order retention in seconds:name(optional) - GenServer name (defaults to MODULE)
Manually trigger a cleanup (useful for testing).