YamlConfigReader

Config reader that reads configuration from YAML file.

Extends: FileConfigReader

Description

The YamlConfigReader allows you to create a config reader that reads a configuration from a YAML file.

Configuration parameters

  • path: path to the configuration file
  • parameters: this entire section is used as template parameters

Constructors

Creates a new instance of the config reader.

YamlConfigReader([String? path])

  • path: String? - (optional) path to the configuration file.

Instance methods

readConfig

Reads a configuration and parameterizes it with given values.

@override

Future<ConfigParams> readConfig(String? correlationId, ConfigParams parameters)

  • correlationId: String? - (optional) transaction id to trace execution through a call chain.
  • parameters: ConfigParams - values of the configuration parameters or null to skip parameterization.
  • returns: Future<ConfigParams> - ConfigParams configuration.

readObject

Reads a configuration file, parameterizes its content and converts it into a YAML object.

dynamic readObject(String? correlationId, ConfigParams parameters)

  • correlationId: String? - (optional) transaction id used to trace execution through a call chain.
  • parameters: ConfigParams - values of the configuration parameters.
  • returns: dynamic - YAML object with a configuration.

Static methods

readConfig_

Reads a configuration from a file, parameterizes it with given values and returns a new ConfigParams object.

static ConfigParams readConfig_(String? correlationId, String path, ConfigParams parameters)

  • correlationId: String? - (optional) transaction id used to trace execution through the call chain.
  • path: String - path to the configuration file.
  • parameters: ConfigParams - values of the configuration parameters.
  • returns: ConfigParams - ConfigParams configuration.

readObject_

Reads a configuration file, parameterizes its content and converts it into a YAML object.

static dynamic readObject_(String? correlationId, String path, ConfigParams parameters)

  • correlationId: String? - (optional) transaction id used to trace the execution through the call chain.
  • path: String - path to the configuration file.
  • parameters: ConfigParams - values of the configuration parameters.
  • returns: dynamic - YAML object containing a configuration.

Examples

key1: "{{KEY1_VALUE}}"
key2: "{{KEY2_VALUE}}"
var configReader = YamlConfigReader('config.yml');
var parameters = ConfigParams.fromTuples('KEY1_VALUE', 123, 'KEY2_VALUE', 'ABC');
var config = await configReader.readConfig('123', parameters)
// Result: key1=123;key2=ABC

See also