QolUp.ConfigFile (qol_up v1.0.3)
GenServer that reads from a config file.
Link to this section Summary
Types
The name of a configuration item, the list variation is for nesting of items.
List of options
Available options for the GenServer
Functions
Returns a specification to start this module under a supervisor.
Get a config item by name or path through config file
Get an item, raising if not found. See get_item/1
Parse the config file. This is automatically called when the
genserver starts. Call it again if the config file changes and
need to be reloaded. If watch_file_system: true
is passed to
start_link/1
, then the GenServer will automatically watch
the config file and will automatically reload it when it
changes.
Put a config item by name or path. This does not update an underlying config file; it is only an in-memory ephemeral change.
Start the genserver
Link to this section Types
item_name()
Specs
The name of a configuration item, the list variation is for nesting of items.
opts_list()
Specs
opts_list() :: [opts_t()]
List of options
opts_t()
Specs
Available options for the GenServer
Link to this section Functions
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
get_item(name \\ __MODULE__, item)
Specs
Get a config item by name or path through config file
Parameters
get_item!(name \\ __MODULE__, item)
Specs
Get an item, raising if not found. See get_item/1
Parameters
name
The name of the GenServeritem
[String.t] or String.t An item or path to an item to retrieve As in "foo", or ["foo"], or ["foo", "bar"]
Returns
- value
parse_config_file(name \\ __MODULE__)
Specs
Parse the config file. This is automatically called when the
genserver starts. Call it again if the config file changes and
need to be reloaded. If watch_file_system: true
is passed to
start_link/1
, then the GenServer will automatically watch
the config file and will automatically reload it when it
changes.
Parameters
put_item(name \\ __MODULE__, item, value)
Specs
Put a config item by name or path. This does not update an underlying config file; it is only an in-memory ephemeral change.
Parameters
name
The name of the GenServeritem
[String.t] or String.t An item or path to an item to retrieve As in "foo", or ["foo"], or ["foo", "bar"]
value
String.t value to assign toitem
Returns
:ok
All is well
start_link(opts)
Specs
start_link(opts_list()) :: GenServer.on_start()
Start the genserver
Parameters
opts
, anopts_list()
:- name Name to give the GenServer; if not specified, then
QolUp.ConfigFile
is used. - config_file Path to the config file to load, required
- watch_fs Whether (true) or not to watch the config file and automatically reload it when it changes, defaults to false
- name Name to give the GenServer; if not specified, then