Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MemoryConfigReader

Config reader that stores configuration in memory.

The reader supports parameterization using Handlebars template engine: https://handlebarsjs.com

Configuration parameters

The configuration parameters are the configuration template

see

IConfigReader

Example

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

let configReader = new MemoryConfigReader();
configReader.configure(config);

let parameters = ConfigParams.fromValue(process.env);

configReader.readConfig("123", parameters, (err, config) => {
    // Possible result: connection.host=10.1.1.100;connection.port=8080
});

Hierarchy

  • MemoryConfigReader

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Protected _config

_config: ConfigParams = new ConfigParams()

Methods

configure

  • configure(config: ConfigParams): void
  • Configures component by passing configuration parameters.

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

readConfig

  • readConfig(correlationId: string, parameters: ConfigParams, callback: function): void
  • Reads configuration and parameterize it with given values.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • parameters: ConfigParams

      values to parameters the configuration or null to skip parameterization.

    • callback: function

      callback function that receives configuration or error.

        • (err: any, config: ConfigParams): void
        • Parameters

          • err: any
          • config: ConfigParams

          Returns void

    Returns void

Generated using TypeDoc