Extension to use on the Ash.Resource that will persist events.
event_log
Nested DSLs
Examples
event_log do
clear_records_for_replay MyApp.Events.ClearAllRecords
record_id_type :integer # (default is :uuid)
persist_actor_primary_key :user_id, MyApp.Accounts.User
persist_actor_primary_key :system_actor, MyApp.SystemActor, attribute_type: :string
end
Options
Name | Type | Default | Docs |
---|
clear_records_for_replay | module | | A module with the AshEvents.ClearRecords-behaviour, that is expected to clear all records before an event replay. |
record_id_type | any | :uuid | The type of the primary key used by the system, which will be the type of the record_id -field on the events. Defaults to :uuid. |
event_log.persist_actor_primary_key
persist_actor_primary_key name, destination
Store the actor's primary key in the event if an actor is set, and the actor matches the resource type. You can define an entry for each actor type.
Examples
persist_actor_primary_key :user_id, MyApp.Accounts.User
persist_actor_primary_key :system_actor, MyApp.SystemActor
Arguments
Name | Type | Default | Docs |
---|
name | atom | | The name of the field to use for the actor primary_key (e.g. :user_id) |
destination | module | | The resource of the actor (e.g. MyApp.Accounts.User) |
Options
Name | Type | Default | Docs |
---|
allow_nil? | boolean | true | Whether this attribute can be nil. If false, the attribute will be required. |
attribute_type | any | :uuid | The type of the generated attribute. See Ash.Type for more. |
public? | boolean | false | Whether this relationship should be included in public interfaces |
Introspection
Target: AshEvents.EventLog.PersistActorPrimaryKey
replay_overrides
Nested DSLs
replay_overrides.replay_override
replay_override event_resource, event_action
Overrides the default event replay behavior for a specific resource action.
Nested DSLs
Examples
replay_overrides do
replay_override MyApp.Accounts.User, :create do
versions [1]
route_to MyApp.Accounts.User, :create_v1
end
end
Arguments
Name | Type | Default | Docs |
---|
event_resource | atom | | The name of the resource stored in the event, that you want to match on. |
event_action | atom | | The name of the action stored in the event, that you want to match on. |
Options
Name | Type | Default | Docs |
---|
versions | list(integer) | | A list of event versions to match on. |
replay_overrides.replay_override.route_to
route_to resource, action
Routes the event to a different action.
Arguments