The following documentation is automatically generated. Please do not edit this file, but rather the original, inline with Myriad::Config at lib/Myriad/Config.pm (on the system that originally ran this). If you do edit this file, and don't want your changes to be removed, make sure you change the first line.
NAME
Myriad::Config - dynamic configuration management for microservices
DESCRIPTION
Configuration support.
PACKAGE VARIABLES
DEFAULTS
The %DEFAULTS
hash provides base values that will be used if no other configuration file, external storage or environment variable provides an alternative.
FULLNAME_FOR
The %FULLNAME_FOR
hash maps commandline shortcuts for common parameters.
SERVICES_CONFIG
A registry of configs defined by the services using the config
helper.
ACTIVE_SERVICES_CONFIG
A collection of Ryu::Observable to notify services about updates on the configs values
clear_key
Delete a single config the best use case for this sub is during tests.
clear_all
Delete all the config that has been parsed by this module, the best use case for this sub is during tests.
parse_subargs
A helper to resolve the correct service config
input is expected to look like <service_name>_[configs|instances].<key>
and this sub will set the correct path to key with the provided value.
Example:
dummy_service.configs.password
will end up in
$config->{services}->{dummy_service}->{configs}->{password}
it takes:
subarg
- the arguments as passed by the user.root
- the level in which we should add the sub arg, we start from $config->{services}.value
- the value that we should assign after resolving the config path.
lookup_from_args
Parse the arguments provided from the command line.
There are many modules that can parse command lines arguments but in our case we have unknown arguments - the services configs - that might be passed by the user or might not and they are on top of that nested.
This sub simply start looking for a match for the arg at hand in %DEFAULTS
then it searches in the shortcuts map and lastly it tries to parse it as a subarg.
Currently this sub takes into account flags (0|1) configs and config written as: config=value
lookup_from_env
Tries to find environments variables that start with MYRIAD_* and parse them.
lookup_from_file
Fill the config from the config file
this sub doesn't do much currently since the config structure is modelled exactly like how it should be in the file so it just read the file.
service_config
Takes a service base package and its current name and tries to resolve its config from:
1. The framework storage itself (i.e Redis or Postgres ..etc). 2. From the config parsed earlier (cmd, env, file).
and if it fails to find a required config it will throw an error.
it takes
pkg
- The package name of the service, will be used to lookup for generic configservice_name
- The current service name either from the registry or as it bassed by the user, useful for instances config
from_storage
Tries to find the config key in the storage using Myriad::Storage.
it takes
service_name
- The service name.instance
- If the service has many instances (e.g demo, production) this should the identifier.key
- The required config key (e.g password, username ..etc).
INHERITED METHODS
AUTHOR
Deriv Group Services Ltd. DERIV@cpan.org
.
See "CONTRIBUTORS" in Myriad for full details.
LICENSE
Copyright Deriv Group Services Ltd 2020-2021. Licensed under the same terms as Perl itself.