Fact.EventTypeIndexer (Fact v0.1.0)

View Source

Index events by their event type.

Summary

Functions

Returns a specification to start this module under a supervisor.

Extracts the type of the event.

Starts the indexer process.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

index_event(schema, event, opts)

Extracts the type of the event.

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.EventTypeIndexer.index_event(event, [])
"ClutchLaid"

iex> event = %{
...>   "event_type" => "EggHatched", 
...>   "event_data" => %{"turtle_id" => "t2", "clutch_id" => "c1"}, 
...>   "event_tags" => ["turtle:t2", "clutch:c1"], 
...> } 
iex> Fact.EventTypeIndexer.index_event(event, [])
"EggHatched"

iex> event = %{
...>   "event_type" => "DatabaseCreated", 
...>   "event_data" => %{"database_id" => "RVX27QR6PFDORJZF24C4DIICSQ"}, 
...>   "stream_id" => "__fact", 
...>   "stream_position" => "1"
...> }
iex> Fact.EventTypeIndexer.index_event(event, [])
"DatabaseCreated"

start_link(opts \\ [])

Starts the indexer process.