Supervisor that manages a Chronicle connection and all registered observers.
Chronicle.Client is the main entry point for the Chronicle Elixir client.
Start it in your application's supervision tree, providing a connection
string and the list of event types, reactors, reducers, and read models to
register.
Usage
In your Application.start/2:
def start(_type, _args) do
children = [
{Chronicle.Client,
connection_string: "chronicle://localhost:35000?disableTls=true",
event_store: "my-store",
event_types: [
MyApp.Events.AccountOpened,
MyApp.Events.FundsDeposited
],
reactors: [MyApp.Reactors.NotificationReactor],
reducers: [MyApp.Reducers.AccountReducer],
read_models: [MyApp.ReadModels.Account]}
]
Supervisor.start_link(children, strategy: :one_for_one)
endRead models that contain from/2, join/2, or removed_with/2 declarations
are automatically registered as server-side projections.
Multiple clients
You can start multiple clients with different names:
{Chronicle.Client,
name: :bank_chronicle,
connection_string: "chronicle://bank-server:35000",
event_store: "bank"}
{Chronicle.Client,
name: :crm_chronicle,
connection_string: "chronicle://crm-server:35000",
event_store: "crm"}Options
:name— registered name for this client. Defaults toChronicle.Client.:connection_string— a connection string binary orChronicle.Connections.ConnectionStringstruct. Defaults toConnectionString.default/0(localhost:35000).:event_store— the event store name. Defaults to"default".:namespace— the namespace within the event store. Defaults to"default".:event_types— list of event type modules to register with the event store.:reactors— list of reactor modules to start (eachuse Chronicle.Reactor).:reducers— list of reducer modules to start (eachuse Chronicle.Reducer).:read_models— list of read model modules (eachuse Chronicle.ReadModel). Modules that containfrom/2declarations are registered as projections.
Convenience functions
Once started, use Chronicle.append/3 and Chronicle.read_model/3 for the
most common operations, or use the subsystem modules directly:
Chronicle.EventLog— append and query eventsChronicle.ReadModels— query read model instancesChronicle.EventTypes— manage event type registrations
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the stored configuration for the given client name.
Starts a Chronicle client supervisor linked to the current process.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Returns the stored configuration for the given client name.
Used internally by Chronicle.EventLog, Chronicle.ReadModels, etc.
@spec start_link(keyword()) :: Supervisor.on_start()
Starts a Chronicle client supervisor linked to the current process.