MemoryConfigReader

Config reader that stores a configuration in memory.

Inherits: IConfigReader, IReconfigurable

Description

The MemoryConfigReader class allows you to create a config reader that stores a configuration in memory.

Configuration parameters

The configuration parameters are the configuration template

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

Constructors

Creates a new instance of a config reader.

public MemoryConfigReader(ConfigParams config = null)

  • config: ConfigParams - (optional) component configuration parameters

Fields

_config

protected _config: ConfigParams = new ConfigParams()

Instance methods

Configure

Configures a component by passing its configuration parameters.

public void Configure(ConfigParams config)

  • config: ConfigParams - configuration parameters to be set.

ReadConfig

Reads a configuration and parameterizes it with given values.

public virtual ConfigParams ReadConfig(string correlationId, ConfigParams parameters)

  • correlationId: string - (optional) transaction id to trace execution through a call chain.
  • parameters: ConfigParams - values to parameters the configuration or null to skip parameterization.
  • returns: ConfigParams - ConfigParams configuration.

Examples


var config = ConfigParams.FromTuples(
    "connection.host", "{{SERVICE_HOST}}",
    "connection.port", "{{SERVICE_PORT}}{{^SERVICE_PORT}}8080{{/SERVICE_PORT}}"
);

var configReader = new MemoryConfigReader();
configReader.Configure(config);

var parameters = ConfigParams.fromValue(process.env);
configReader.ReadConfig("123", parameters);