Fact.Supervisor (Fact v0.2.0)
View SourceTop-level supervisor for the Fact database system.
Fact.Supervisor is the root of the supervision tree and is responsible for
starting and supervising all database instances for the lifetime of the system.
This module is responsible for:
- Owning the Fact supervision tree
- Managing database lifecycle and supervision
- Coordinating database startup through
Fact.Bootstrapper.
It does not expose database APIs or persistence operations; it is concerned solely with system structure and process lifecycle.
Summary
Types
Option values used by the start_link/1 function.
Functions
Returns a specification to start this module under a supervisor.
Starts a database at the given filesystem path.
Starts the Fact.Supervisor.
Types
@type option() :: {:databases, [Path.t()]}
Option values used by the start_link/1 function.
{:databases, paths}- A list of file-system paths identifying databases that should be bootstrapped automatically at startup.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_database(Path.t()) :: {:ok, Fact.database_id()} | {:error, :database_locked, Fact.Lock.metadata_record()} | {:error, :database_failure} | {:error, term()}
Starts a database at the given filesystem path.
This function delegates startup to a Fact.Bootstrapper process under this supervisor and waits
for a startup acknowledgement message.
The caller will block until one the following occurs:
- The database is successfully started and the database identifier is returned
- The database is already locked by another process
- An error occurs during initialization.
- The startup process times out.
Process interaction
The bootstrapper is started as a supervised child and is expected to send of the following messages back to the calling process:
{:database_started, database_id}{:database_locked, lock_metadata}{:database_error, reason}
If no message is received within 3 seconds, the call fails with {:error, :database_failure}
@spec start_link([option()]) :: Supervisor.on_start()
Starts the Fact.Supervisor.
At startup, the supervisor:
- Starts the global
Fact.Registry, used for process andFact.Contextlookup across the system. - Bootstraps any databases specified via the
:databasesoption by starting aFact.Bootstrapperprocess for each configured path.
Databases listed in the :databases option are started eagerly as part of supervisor initialization.
Additional databases may be started later at runtime using start_database/1.