AshDispatch.Resource.Transformers.InjectCounterBroadcasts (AshDispatch v0.5.0)

View Source

Transformer that registers AshDispatch.Notifier and persists per-action counter-broadcast config for resources using the counters DSL block.

Pattern (post-tx-semantics retrofit)

Pre-retrofit, this transformer injected change AshDispatch.Changes.BroadcastCounterUpdate per action. The change fired via Ash.Changeset.after_action/2 synchronously inside the action's transaction BEFORE commit/rollback, allowing phantom counter increments to broadcast for rolled-back rows. Post-retrofit, counter logic runs from AshDispatch.Notifier's post-commit notification path (or is dropped on error). See AshDispatch.Notifier moduledoc for the architectural rationale.

Persisted state

  • :ash_dispatch_counter_broadcasts — NEW; %{action_name => [counter_config_keyword_list, ...]} for the notifier to consume per-action.
  • :simple_notifiers — adds AshDispatch.Notifier (idempotent if InjectDispatchChanges already registered it).

Summary

Functions

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(_)

Callback implementation for Spark.Dsl.Transformer.before?/1.