ExESDB.System (ex_esdb v0.11.0)
This module is the top level supervisor for the ExESDB system.
It uses a layered supervision architecture for better fault tolerance:
SINGLE NODE MODE:
- PubSubSystem: Message distribution infrastructure
- LoggingSystem: Structured logging and event processing
- CoreSystem: Critical infrastructure (PersistenceSystem + NotificationSystem + StoreSystem)
- GatewaySystem: External interface with pooled workers
CLUSTER MODE:
- PubSubSystem: Message distribution infrastructure
- LoggingSystem: Structured logging and event processing
- CoreSystem: Critical infrastructure (PersistenceSystem + NotificationSystem + StoreSystem)
- LibCluster: Node discovery and connection (after core is ready)
- ClusterSystem: Cluster coordination and membership
- GatewaySystem: External interface (LAST - only after clustering is ready)
NotificationSystem (part of CoreSystem) includes:
- LeaderSystem: Leadership responsibilities and subscription management
- EmitterSystem: Event emission and distribution
IMPORTANT: Core functionality (Store, Persistence) must be fully operational before any clustering/membership/registration components start. This ensures the server is ready to handle requests before announcing itself to the cluster.
In cluster mode, GatewaySystem starts LAST to prevent external connections until the entire distributed system is properly initialized.
Note: Store management is now handled by the distributed ex-esdb-gater API.
Summary
Functions
Returns a specification to start this module under a supervisor.
Start ExESDB.System with automatic configuration discovery.
Generate a store-specific name for this system supervisor.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Start ExESDB.System with automatic configuration discovery.
This function supports several modes:
- With explicit opts:
ExESDB.System.start_link(opts)
- uses provided configuration - With OTP app name:
ExESDB.System.start_link(:my_app)
- discovers config from specified app - With empty opts or no args:
ExESDB.System.start_link([])
orExESDB.System.start_link()
- discovers config from calling application
Examples
# Explicit configuration (current approach)
opts = ExESDB.Options.app_env(:my_app)
ExESDB.System.start_link(opts)
# Auto-discovery from specific app
ExESDB.System.start_link(:my_app)
# Auto-discovery from calling application
ExESDB.System.start_link()
Generate a store-specific name for this system supervisor.
This allows multiple ExESDB systems to run on the same node with different stores.
Examples
iex> ExESDB.System.system_name("my_store")
:"exesdb_system_my_store"
iex> ExESDB.System.system_name(nil)
ExESDB.System