AshAuthentication.AuditLogResource.Batcher (ash_authentication v4.13.3)

View Source

A GenServer which batches up writes to the audit log to reduce write pressure in busy environments.

Scans all audit log resources based on their configured write batching options.

defmodule MyApp.Accounts.AuditLog do
  use Ash.Resource,
    extensions: [AshAuthentication.AuditLogResource],
    domain: MyApp.Accounts


  audit_log do
    write_batching do
      enabled? true
      timeout :timer.seconds(10)
      max_size 100
    end
  end
end

This GenServer is started by the AshAuthentication.Supervisor which should be added to your app's supervision tree.

Summary

Functions

Returns a specification to start this module under a supervisor.

Queues an event for writing.

Flushes all queued events to the database immediately.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

enqueue(changeset)

Queues an event for writing.

flush()

Flushes all queued events to the database immediately.

Useful for testing to ensure all audit log entries are written before assertions.