Fact.EventStreamIndexer (Fact v0.2.0)
View SourceIndex events by their event stream if specified.
Summary
Functions
Returns a specification to start this module under a supervisor.
Extracts the stream name of the event.
Gets the friendly name for the indexer.
Utility method to determine the last position within an event stream.
Returns 0 if the event stream does not exist.
Starts the indexer process.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Extracts the stream name of the event.
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.EventStreamIndexer.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.EventStreamIndexer.index_event(event, [])
nil
iex> event = %{
...> "event_type" => "DatabaseCreated",
...> "event_data" => %{"database_id" => "RVX27QR6PFDORJZF24C4DIICSQ"},
...> "stream_id" => "__fact",
...> "stream_position" => "1"
...> }
iex> Fact.EventStreamIndexer.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 last_stream_position(Fact.database_id(), Fact.event_stream_id()) :: Fact.event_position()
Utility method to determine the last position within an event stream.
Returns 0 if the event stream does not exist.
This is similar to Fact.Database.last_position/1, but for a stream.
@spec start_link([Fact.EventIndexer.option()]) :: GenServer.on_start()
Starts the indexer process.