AshEvents.EventLog

View Source

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

NameTypeDefaultDocs
clear_records_for_replaymoduleA module with the AshEvents.ClearRecords-behaviour, that is expected to clear all records before an event replay.
record_id_typeany:uuidThe 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

NameTypeDefaultDocs
nameatomThe name of the field to use for the actor primary_key (e.g. :user_id)
destinationmoduleThe resource of the actor (e.g. MyApp.Accounts.User)

Options

NameTypeDefaultDocs
allow_nil?booleantrueWhether this attribute can be nil. If false, the attribute will be required.
attribute_typeany:uuidThe type of the generated attribute. See Ash.Type for more.
public?booleanfalseWhether 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

NameTypeDefaultDocs
event_resourceatomThe name of the resource stored in the event, that you want to match on.
event_actionatomThe name of the action stored in the event, that you want to match on.

Options

NameTypeDefaultDocs
versionslist(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

NameTypeDefaultDocs
resourceatom
actionatom