Chronicle.Events.EventTypes (cratis_chronicle v0.2.0)

Copy Markdown View Source

Registers event types with a Chronicle event store.

Called automatically by Chronicle.Registration.Coordinator during startup. You can also call it directly to register event types at runtime.

Example

{:ok, channel} = Chronicle.Connections.Connection.channel(:my_conn)

:ok =
  Chronicle.Events.EventTypes.register(
    channel,
    "my-store",
    [MyApp.Events.AccountOpened],
    [MyApp.Migrations.AccountOpenedV2Migration]
  )

Summary

Functions

Registers event type modules and their migrations with Chronicle.

Functions

register(channel, event_store, event_type_modules, migration_modules \\ [])

@spec register(term(), String.t(), [module()], [module()]) :: :ok | {:error, term()}

Registers event type modules and their migrations with Chronicle.

Each event type module must use Chronicle.Events.EventType. Chronicle groups all known generations of the same event type into a single registration, includes schemas for each known generation, and attaches any registered migrations.

Returns :ok on success or {:error, reason} on failure.