Fact.EventStreamCategoryIndexer (Fact v0.2.0)
View SourceIndexes events by the category portion of an event stream, by splitting the string on a specified separator and returns the first segment.
Summary
Types
The id for a Fact.EventStreamCategoryIndexer.
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 a category from an event stream id.
Gets the friendly name for the indexer.
Starts the indexer process.
Types
@type id() :: {Fact.EventStreamCategoryIndexer, nil}
The id for a Fact.EventStreamCategoryIndexer.
@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 a category from an event stream id.
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"
...> }
iex> Fact.EventStreamCategoryIndexer.index_event(event, [])
"turtle_mating"
iex> event = %{
...> "event_type" => "EggHatched",
...> "event_data" => %{"turtle_id" => "t2", "clutch_id" => "c1"},
...> "event_tags" => ["turtle:t2", "clutch:c1"],
...> }
iex> Fact.EventStreamCategoryIndexer.index_event(event, [])
nil
iex> event = %{
...> "event_type" => "DatabaseCreated",
...> "event_data" => %{"database_id" => "RVX27QR6PFDORJZF24C4DIICSQ"},
...> "stream_id" => "__fact",
...> "stream_position" => 1
...> }
iex> Fact.EventStreamCategoryIndexer.index_event(event, [])
"__fact"
@spec indexer_name() :: String.t()
Gets the friendly name for the indexer.
This is included in the file path where index files are stored on disk.
@spec start_link([Fact.EventIndexer.option()]) :: GenServer.on_start()
Starts the indexer process.