Configuration » History » Version 2

« Previous - Version 2/15 (diff) - Next » - Current version
J. Moringen, 05/18/2011 01:14 PM
note about scope of configuration


Configuration

The configuration mechanism is based on the following principles:
  • We cannot (and do not want) to handle configuration of individual participants. The configuration mechanism is intended to provide process-wide defaults. Participants that require individual configurations have to be configured programmatically.
  • The configuration mechanism works identically across implementation languages
  • Configuration options are obtained from multiple configuration sources:
    • Configuration files
    • Environment variables
    • Commandline options (planned)
  • Configuration options are organized in a tree of name-value pairs

Syntax and Semantics

Option names consist of multiple components which are specified in configuration-source-dependent syntax. For example, in configuration files section names like [transport.spread] are concatenated with names of contained options like port to obtain transport.spread.port. For environment variables, the name RSB_TRANSPORT_SPREAD_PORT maps to transport.spread.port.

Currently the following option tree is defined (uppercase option name components are placeholders):

+ qualityofservice
+-- reliability                     { UNRELIABLE, RELIABLE }
+-- ordering                        { UNORDERED, ORDERED }
+ errorhandling
+-- onhandlererror                  { LOG, PRINT, EXIT }
+ transport
+-- NAME
+---- enabled                       bool
+---- TRANSPORT_SPECIFIC_OPTION     ?
+---- converter
+------ WIRE-SCHEMA                 string
+-- spread
+---- host                          string
+---- port                          uint
+-- inprocess

Processing Order

Configuration sources are processed in the following order such that options from sources which are processed later take precedence over options from sources which are processed earlier:
  1. Config file ${HOME}/.config/rsb.conf
  2. Config file $(pwd)/rsb.conf
  3. Environment variables

Example and test case

Consider the following situation:
  • Contents of ${HOME}/.config/rsb.conf:
    [transport.spread]
    host = azurit
    port = <uint>5301
    
  • Contents of (pwd)/rsb.conf
    [transport.spread]
    host = localhost
    
  • Environment Variables
    RSB_TRANSPORT_SPREAD_PORT='<unit>4444'
This would result in the following effective option values:
  • transport.spread.host = localhost
  • transport.spread.port = 4444

Sources

The following sections briefly explains the currently defined configuration sources.

Configuration Files

Configuration files use the following syntax, which is similar to INI-files or desktop-files:
  • Comments are initiated by the # character and extend to the end of the current line
  • After removing comments, all lines have to be of one of the following forms:
    • empty
    • [NAME] where NAME consists of alphanumeric characters and colons
    • NAME = VALUE where NAME consists of alphanumeric characters

Here is an example:

[qualityofservice]
reliability = UNRELIABLE
ordering = UNORDERED

[errorhandling]
onhandlererror = LOG

[transport.spread]
host    = localhost
port    = <uint>4803
enabled = <bool>1 # this is the default

[transport.spread.converter]
image = IplImage # wireSchema = dataType

[transport.inprocess]
foo     = barbar
factor  = <double>1.5
enabled = <bool>1

Environment Variables

Environment variables are processed according to the following rules
  1. Variables whose names start with RSB_ are processed
  2. The RSB_ prefix is stripped form the name
  3. To obtain the name of the corresponding option, the remainder of the name is converted to lower case and split at _ characters

Example:
RSB_TRANSPORT_SPREAD_PORT -> transport.spread.port