API Docs for: 1.1.0
Show:

Configuration Class

Defined in: lib\index.js:3
Module: a-configuration

Configurations load in 2 stages.

The first stage is a blocking file read to provide base data for the application and base configurations as described by the system.

The second stage is to load data from extended data sources in a non-blocking fashion. A _await property is provided as a Promise to allow for waiting for the full configuration load if desired.

Note that as this extends an EventEmitter, colliding key names should be avoided, such as "on" and "once". Due to the nature of the EventEmitter properties and for simplicity, Configuration merely extends the EventEmitter class so that configuration.on and similar methods are simply available without needing to remember referencing such as configuration._events.on, however the extended event emitted is also available as _events to allow for key collision if needed.

Additionally, this module binds a listener to the "SIGHUP" Process Event to trigger configuration reload events.

Methods

_reload

() Promise

Defined in lib\index.js:337

Update the configurations.

This will cause all configuration sources to be read again and then applied over the current configuration. Which will change values that exist but will in general not delete values.

Specifically this will not remove values at the first, or second level due to the way in which the configurations are assembled. Keys at the third level or deeper will fall off IF the second level key has an update applied.

Returns:

Promise:

Resolves with the final status of the configuration loading; See: "loaded" and "error" events.

getExt

(
  • path
)
Boolean private

Defined in lib\index.js:111

Parameters:

  • path String

    File name or complete file path.

Returns:

Boolean:

initialized.failure

(
  • exception
)
private

Defined in lib\index.js:69

Called if the first completion of the second load stage resulted in an exception.

Parameters:

  • exception Error

    The thrown exception

initialized.success

() private

Defined in lib\index.js:64

Called after the first completion of the second load stage.

isLocked

() Boolean private

Defined in lib\index.js:323

Indicate if the configuration module is currently updating.

This currently responds to the following states:

  • reloading

Returns:

Boolean:

loadConfigurations

() private

Defined in lib\index.js:167

loadFailed

(
  • exception
)
Promise private

Defined in lib\index.js:122

Parameters:

  • exception Error

Returns:

Promise:

loadFailed

(
  • exception
)
Promise private

Defined in lib\index.js:144

Parameters:

  • exception Error

Returns:

Promise:

loadFile

(
  • file
)
private

Defined in lib\index.js:175

Parameters:

  • file String

    Filename to load.

readJSON

(
  • path
)
Object private

Defined in lib\index.js:89

Parameters:

  • path String

Returns:

Object:

resolveConfiguration

(
  • conf
)
private

Defined in lib\index.js:213

Parameters:

  • conf Object

    Configuration to resolve against the current export.

Properties

_await

Promise

Defined in lib\index.js:77

Called after the first completion of the second load stage.

_emitter

EventEmitter

Defined in lib\index.js:36

Provides a reference to the extended event emitter to allow for key collisions off of the configuration object itself.

_events

Object private

Defined in lib\index.js:44

Maps event names to their current name for consistency.

loaded

Object private

Defined in lib\index.js:55

Tracks included javascript file configurations so that reloads can be triggered via their functional invocations.

reloading

Boolean private

Defined in lib\index.js:313

When true, the configuration is updating its values. This does not block the values from being used, but does indicate that the module is busy and operations that would cause further updates should be blocked.

Events

failed

Defined in lib\index.js:152

Thrown in the case of an error in any stage.

Event Payload:

  • conf Configuration

    This configuration that finished loading.

  • error Error

    Thrown exception

loaded

Defined in lib\index.js:130

Event Payload: