MscmpSystDb.Datastore (mscmp_syst_db v0.1.0)
Provides basic OTP related features for Datastores.
Functions in this module support running Datastores under supervision and creates a Datastore supervisor for managing Datastore Context worker processes.
Summary
Functions
Provides a Datastore child specification for use with supervisors.
Starts the Datastore Supervisor and its requested child Datastore Contexts.
Functions
child_spec(datastore_options, opts \\ [])
@spec child_spec(MscmpSystDb.Types.DatastoreOptions.t(), Keyword.t()) :: Supervisor.child_spec()
Provides a Datastore child specification for use with supervisors.
Note that this function is not child_spec/1
as expected when a Supervisor
attempts to start a process based on the module name alone. This is because
there is a required parameter which renders that method of starting a process
invalid as there's no default value for the parameter (datastore_options
).
Parameters
datastore_options
- a required Map of values which describe the Datastore and Datastore Context related connection options. SeeMscmpSystDb.Types.DatastoreOptions.t/0
for more.opts
- a Keyword list of various options accepted or required by theDynamicSupervisor.start_link/1
function. Note that we provide some default values:strategy: :one_for_one
,restart: :transient
,timeout: 60_000
, and the:name
option is defaulted to thedatastore_options.datastore_name
value.
start_link(opts \\ [])
@spec start_link(Keyword.t()) :: Supervisor.on_start()
Starts the Datastore Supervisor and its requested child Datastore Contexts.
When this function is called, a new DynamicSupervisor
for the datastore is
started and any Datastore Contexts which are identified in the
datastore_options
are also started and places under the Datastore
Supervisor.
Options
name
- establishes the name of the Datastore Supervisor and accepts any name which is valid according to the documentation forGenServer
. The default value for this parameter is thedatastore_name
value found in thedatastore_options
attribute which configures the Datastore.datastore_options
- a required Map of values which describe the Datastore and Datastore Context related connection options. SeeMscmpSystDb.Types.DatastoreOptions.t/0
for more.