Fact.DatabaseSupervisor (Fact v0.3.1)

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.

Runtime options for database subsystems, passed via the :opts key.

Functions

Returns a specification to start this module under a supervisor.

Types

option()

(since 0.3.0)
@type option() :: {:context, Fact.Context.t()} | {:opts, [subsystem_option()]}

Options used when starting a Fact.DatabaseSupervisor.

  • :context - (required) The Fact.Context providing database identity and configuration.
  • :opts - (optional) Runtime options for database subsystems. See subsystem_option/0.

subsystem_option()

(since 0.3.0)
@type subsystem_option() ::
  {:cache, [Fact.RecordCache.cache_option()]}
  | {:merkle, [Fact.MerkleMountainRange.merkle_option()]}
  | {:wal, [Fact.WriteAheadLog.wal_option()]}

Runtime options for database subsystems, passed via the :opts key.

Functions

child_spec(init_arg)

(since 0.3.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. Optionally accepts :opts for database subsystem configuration. See subsystem_option/0.

start_link(opts)

(since 0.3.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.