Configuration » History » Version 1

J. Moringen, 05/16/2011 11:08 AM
intial version

1 1 J. Moringen
h1. Configuration
2 1 J. Moringen
3 1 J. Moringen
The configuration mechanism is based on the following principles:
4 1 J. Moringen
* The configuration mechanism works identically across implementation languages
5 1 J. Moringen
* Configuration options are obtained from multiple configuration sources:
6 1 J. Moringen
** Configuration files
7 1 J. Moringen
** Environment variables
8 1 J. Moringen
** _Commandline options (planned)_
9 1 J. Moringen
* Configuration options are organized in a tree of name-value pairs
10 1 J. Moringen
11 1 J. Moringen
h2. Syntax and Semantics
12 1 J. Moringen
13 1 J. Moringen
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@.
14 1 J. Moringen
15 1 J. Moringen
Currently the following option tree is defined (uppercase option name components are placeholders):
16 1 J. Moringen
<pre>
17 1 J. Moringen
+ qualityofservice
18 1 J. Moringen
+-- reliability                     { UNRELIABLE, RELIABLE }
19 1 J. Moringen
+-- ordering                        { UNORDERED, ORDERED }
20 1 J. Moringen
+ errorhandling
21 1 J. Moringen
+-- onhandlererror                  { LOG, PRINT, EXIT }
22 1 J. Moringen
+ transport
23 1 J. Moringen
+-- NAME
24 1 J. Moringen
+---- enabled                       bool
25 1 J. Moringen
+---- TRANSPORT_SPECIFIC_OPTION     ?
26 1 J. Moringen
+---- converter
27 1 J. Moringen
+------ WIRE-SCHEMA                 string
28 1 J. Moringen
+-- spread
29 1 J. Moringen
+---- host                          string
30 1 J. Moringen
+---- port                          uint
31 1 J. Moringen
+-- inprocess
32 1 J. Moringen
</pre>
33 1 J. Moringen
34 1 J. Moringen
h2. Processing Order
35 1 J. Moringen
36 1 J. Moringen
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:
37 1 J. Moringen
# Config file @${HOME}/.config/rsb.conf@
38 1 J. Moringen
# Config file @$(pwd)/rsb.conf@
39 1 J. Moringen
# Environment variables
40 1 J. Moringen
41 1 J. Moringen
h3. Example and test case
42 1 J. Moringen
43 1 J. Moringen
Consider the following situation:
44 1 J. Moringen
* Contents of @${HOME}/.config/rsb.conf@:
45 1 J. Moringen
<pre>
46 1 J. Moringen
[transport.spread]
47 1 J. Moringen
host = azurit
48 1 J. Moringen
port = <uint>5301
49 1 J. Moringen
</pre>
50 1 J. Moringen
* Contents of @(pwd)/rsb.conf@
51 1 J. Moringen
<pre>
52 1 J. Moringen
[transport.spread]
53 1 J. Moringen
host = localhost
54 1 J. Moringen
</pre>
55 1 J. Moringen
* Environment Variables
56 1 J. Moringen
  @RSB_TRANSPORT_SPREAD_PORT='<unit>4444'@
57 1 J. Moringen
58 1 J. Moringen
This would result in the following effective option values:
59 1 J. Moringen
* @transport.spread.host = localhost@
60 1 J. Moringen
* @transport.spread.port = 4444@
61 1 J. Moringen
62 1 J. Moringen
h2. Sources
63 1 J. Moringen
64 1 J. Moringen
The following sections briefly explains the currently defined configuration sources.
65 1 J. Moringen
66 1 J. Moringen
h3. Configuration Files
67 1 J. Moringen
68 1 J. Moringen
Configuration files use the following syntax, which is similar to INI-files or desktop-files:
69 1 J. Moringen
* Comments are initiated by the @#@ character and extend to the end of the current line
70 1 J. Moringen
* After removing comments, all lines have to be of one of the following forms:
71 1 J. Moringen
** empty
72 1 J. Moringen
** @[NAME]@ where @NAME@ consists of alphanumeric characters and colons 
73 1 J. Moringen
** @NAME = VALUE@ where @NAME@ consists of alphanumeric characters
74 1 J. Moringen
75 1 J. Moringen
Here is an example:
76 1 J. Moringen
<pre>
77 1 J. Moringen
[qualityofservice]
78 1 J. Moringen
reliability = UNRELIABLE
79 1 J. Moringen
ordering = UNORDERED
80 1 J. Moringen
81 1 J. Moringen
[errorhandling]
82 1 J. Moringen
onhandlererror = LOG
83 1 J. Moringen
84 1 J. Moringen
[transport.spread]
85 1 J. Moringen
host    = localhost
86 1 J. Moringen
port    = <uint>4803
87 1 J. Moringen
enabled = <bool>1 # this is the default
88 1 J. Moringen
89 1 J. Moringen
[transport.spread.converter]
90 1 J. Moringen
image = IplImage # wireSchema = dataType
91 1 J. Moringen
92 1 J. Moringen
[transport.inprocess]
93 1 J. Moringen
foo     = barbar
94 1 J. Moringen
factor  = <double>1.5
95 1 J. Moringen
enabled = <bool>1
96 1 J. Moringen
</pre>
97 1 J. Moringen
98 1 J. Moringen
h3. Environment Variables
99 1 J. Moringen
100 1 J. Moringen
Environment variables are processed according to the following rules
101 1 J. Moringen
# Variables whose names start with @RSB_@ are processed
102 1 J. Moringen
# The @RSB_@ prefix is stripped form the name
103 1 J. Moringen
# To obtain the name of the corresponding option, the remainder of the name is converted to lower case and split at @_@ characters
104 1 J. Moringen
105 1 J. Moringen
Example:
106 1 J. Moringen
@RSB_TRANSPORT_SPREAD_PORT -> transport.spread.port@