Fact.Database (Fact v0.2.0)

View Source

Represents a running Fact database instance and orchestrates indexing, event tracking, and record publishing.

Fact.Database is a GenServer that maintains state about:

  • The database's ledger position
  • Active indexers and their progress
  • Locks for safe concurrent access
  • The last published position to subscribers

This module provides:

  • Reading events, indexes, and the ledger
  • Ensuring and starting indexers
  • Tracking indexer progress and publishing indexed positions
  • High-level coordination of database internals via Fact.Registry and Fact.EventPublisher

Summary

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

ensure_indexer(database_id, indexer_module, options \\ [])

last_position(database_id)

read_event(database_id, record_id)

read_index(database_id, indexer_id, index, read_opts)

read_ledger(database_id, read_opts)

read_none(database_id, read_opts)

read_query(database_id, query_fun, read_opts)

read_record(database_id, record_id)

start_indexer(database_id, indexer_module, options \\ [])

start_link(options)

subscribe(database_id)