MemoryConfigReader

Config reader that stores a configuration in memory.

Implements: 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.

MemoryConfigReader(config: ConfigParams = None)

  • config: ConfigParams - (optional) component configuration parameters

Instance methods

add_change_listener

Adds a listener that will be notified when configuration is changed

add_change_listener(listener: INotifiable)

configure

Configures a component by passing its configuration parameters.

configure(config: ConfigParams)

  • config: ConfigParams - configuration parameters to be set.

read_config_

Reads a configuration and parameterizes it with given values.

read_config_(correlation_id: Optional[str], parameters: ConfigParams): ConfigParams

  • correlation_id: Optional[str] - (optional) transaction id to trace execution through a call chain.
  • parameters: ConfigParams - values to parameters the configuration or None to skip parameterization.
  • returns: ConfigParams - ConfigParams configuration.

remove_change_listener

Remove a previously added change listener.

remove_change_listener(listener: INotifiable): void

Examples

config = ConfigParams.from_tuples(
	"connection.host", "localhost",
	"connection.port", "8080"
)
config_reader = MemoryConfigReader()
config_reader.configure(config)
parameters = ConfigParams.from_value(sys.argv)
config_reader.read_config("123", parameters) # Result: connection.host=localhost;connection.port=8080