Fact.EventStreamsByCategoryIndexer (Fact v0.1.0)
View SourceIndexes the first event of each event stream by the stream category.
Similar to the Fact.EventStreamCategoryIndexer this splits the event stream using a specified separator and returns
the first segment, but behaves like the Fact.EventStreamsIndexer and only indexes the first event of each stream.
This results in creating an index file per-category, each containing the first event in for each stream in the category. It is common in systems for all instances of an Aggregate root to write to the same "category", this indexer makes it easy to find all the instances of that type (e.g. Get All Orders, Get All Customers, etc.).
Summary
Types
Custom option values passed to the Fact.EventIndexer.index_event/3 callback function.
Custom options passed to the Fact.EventIndexer.index_event/3 callback function.
Functions
Returns a specification to start this module under a supervisor.
Extracts the stream category from the first event of each event stream.
Starts the indexer process.
Types
@type option() :: {:separator, String.t()} | Fact.EventIndexer.indexer_option()
Custom option values passed to the Fact.EventIndexer.index_event/3 callback function.
@type options() :: [option()]
Custom options passed to the Fact.EventIndexer.index_event/3 callback function.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Extracts the stream category from the first event of each event stream.
Options
:separator- optional delimiter used to split the stream name. Defaults to "-".
Examples
iex> event = %{
...> "event_type" => "ClutchLaid",
...> "event_data" => %{"turtle_id" => "t1", "clutch_id" => "c1", "eggs" => 42},
...> "event_tags" => ["turtle:t1", "clutch:c1"],
...> "stream_id" => "turtle_mating-1234",
...> "stream_position" => 3
...> }
iex> Fact.EventStreamsByCategoryIndexer.index_event(event, [])
nil
iex> event = %{
...> "event_type" => "EggHatched",
...> "event_data" => %{"turtle_id" => "t2", "clutch_id" => "c1"},
...> "event_tags" => ["turtle:t2", "clutch:c1"],
...> }
iex> Fact.EventStreamsByCategoryIndexer.index_event(event, [])
nil
iex> event = %{
...> "event_type" => "DatabaseCreated",
...> "event_data" => %{"database_id" => "RVX27QR6PFDORJZF24C4DIICSQ"},
...> "stream_id" => "__fact",
...> "stream_position" => 1
...> }
iex> Fact.EventStreamsByCategoryIndexer.index_event(event, [])
"__fact"
Starts the indexer process.