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

constructor

  • Creates a new instance of config reader.

    Parameters

    • Default value config: ConfigParams = null

      (optional) component configuration parameters

    Returns MemoryConfigReader

Properties

Protected _config

_config: ConfigParams = new ConfigParams()

Methods

addChangeListener

  • addChangeListener(listener: INotifiable): void
  • Adds a listener that will be notified when configuration is changed

    Parameters

    • listener: INotifiable

      a listener to be added.

    Returns void

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

removeChangeListener

  • removeChangeListener(listener: INotifiable): void
  • Remove a previously added change listener.

    Parameters

    • listener: INotifiable

      a listener to be removed.

    Returns void

Generated using TypeDoc