Fact.DatabaseSupervisor (Fact v0.2.0)

View Source

Supervises all processes for a single Fact database instance.

Fact.DatabaseSupervisor is the top-level supervisor for a database, responsible for:

  • Registering the database in Fact.Registry
  • Supervising per-database registries and PubSub
  • Starting core database processes.
  • Starting indexers.

Each child process is registered under a database-specific name via Fact.Registry, ensuring isolation between multiple database instances.

This supervisor is automatically started by Fact.Supervisor when a database is initialized, and consumers typically interact with the database through higher-level APIs rather than directly starting this supervisor.

Summary

Types

Options used when starting a Fact.DatabaseSupervisor.

Functions

Returns a specification to start this module under a supervisor.

Types

option()

(since 0.1.0)
@type option() :: {:context, Fact.Context.t()}

Options used when starting a Fact.DatabaseSupervisor.

Current requires a :context, which provides the database identity and configuration needed to scope and register all supervised processes.

Functions

child_spec(init_arg)

(since 0.1.0)
@spec child_spec([option()]) :: Supervisor.child_spec()

Returns a specification to start this module under a supervisor.

The child spec is keyed by Fact.database_id/0, allowing multiple database instances to be supervised concurrently.

Requires the :context option to be specified.

start_link(list)

(since 0.1.0)
@spec start_link([option()]) :: Supervisor.on_start()

Starts a Fact.DatabaseSupervisor.

This supervisor defines the runtime boundary for a single Fact database instance. It is registered under a database-scoped name via Fact.Registry, ensuring full isolation between multiple database instances running in the same VM.

At startup, this supervisor initializes all database-scope infrastructure, including registries, PubSub, core write coordination processes, and event indexers.

This function is typically invoked by Fact.Supervisor as part of database initialization and is not intended to be called directly by application code.