Fact.EventDataIndexer (Fact v0.2.0)

View Source

Index events by the values of a specified key within the event data.

Summary

Types

The id for a Fact.EventDataIndexer.

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.

Retrieves the value for the configured :indexer_key from the event's data payload.

Gets the friendly name for the indexer.

Starts the indexer process.

Types

id()

@type id() :: {Fact.EventDataIndexer, Fact.EventIndexer.indexer_key()}

The id for a Fact.EventDataIndexer.

option()

@type option() :: {:indexer_key, String.t()} | Fact.EventIndexer.indexer_option()

Custom option values passed to the Fact.EventIndexer.index_event/3 callback function.

options()

@type options() :: [option()]

Custom options passed to the Fact.EventIndexer.index_event/3 callback function.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

index_event(schema, event, opts)

Retrieves the value for the configured :indexer_key from the event's data payload.

Options

  • :indexer_key — required, specified the field to lookup within the event data

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.EventDataIndexer.index_event(event, [indexer_key: "eggs"])
"42"

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

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

indexer_name()

(since 0.1.2)
@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.

start_link(opts \\ [])

@spec start_link([Fact.EventIndexer.option()]) :: GenServer.on_start()

Starts the indexer process.