Class EnvReader
java.lang.Object
codes.grow.packages.skywalking.core.EnvReader
Reads configuration from environment variables (SPEC section 2.2).
Each lookup tries <prefix><NAME> first (for example GROW_<KEY>_URL), then the
vendor variables in the given order. An empty value counts as unset. A present but invalid value
raises ConfigException naming the variable, never its value. The environment map is
injectable so tests never touch the real process environment.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReads a boolean (true/false/1/0/yes/no/on/off, case-insensitive).Reads a duration (integer milliseconds or Go-style units such as1m30s).Reads an integer.static EnvReaderCreates a reader withDEFAULT_PREFIXover an explicit map.Parses a boolean:true/false/1/0/yes/no/on/off, case-insensitive.parseDuration(String text) Parses a duration: integer milliseconds (1500) or Go-style units (500ms,10s,2m,1h,1m30s).Returns the name of the first variable that is set, for error messages.Reads a string.static EnvReadersystem()Creates a reader withDEFAULT_PREFIXover the process environment.
-
Field Details
-
DEFAULT_PREFIX
Prefix of every variable of this SDK.- See Also:
-
-
Constructor Details
-
EnvReader
Creates a reader over an explicit environment map.- Parameters:
prefix- prefix for SDK variables, usuallyDEFAULT_PREFIXenv- variable map
-
-
Method Details
-
of
Creates a reader withDEFAULT_PREFIXover an explicit map.- Parameters:
env- variable map- Returns:
- a new reader
-
system
Creates a reader withDEFAULT_PREFIXover the process environment.- Returns:
- a new reader
-
source
Returns the name of the first variable that is set, for error messages.- Parameters:
name- SDK variable name without prefixvendorNames- vendor variables in precedence order- Returns:
- the variable name, or empty
-
string
Reads a string.- Parameters:
name- SDK variable name without prefix, e.g.URLvendorNames- vendor variables in precedence order- Returns:
- the value, or empty when unset
-
duration
Reads a duration (integer milliseconds or Go-style units such as1m30s).- Parameters:
name- SDK variable name without prefixvendorNames- vendor variables in precedence order- Returns:
- the duration, or empty when unset
- Throws:
ConfigException- when the value is invalid
-
bool
Reads a boolean (true/false/1/0/yes/no/on/off, case-insensitive).- Parameters:
name- SDK variable name without prefixvendorNames- vendor variables in precedence order- Returns:
- the value, or empty when unset
- Throws:
ConfigException- when the value is invalid
-
integer
Reads an integer.- Parameters:
name- SDK variable name without prefixvendorNames- vendor variables in precedence order- Returns:
- the value, or empty when unset
- Throws:
ConfigException- when the value is invalid
-
parseDuration
Parses a duration: integer milliseconds (1500) or Go-style units (500ms,10s,2m,1h,1m30s).- Parameters:
text- the value- Returns:
- the duration, or empty when the text is not a valid non-negative duration
-
parseBool
Parses a boolean:true/false/1/0/yes/no/on/off, case-insensitive.- Parameters:
text- the value- Returns:
- the boolean, or empty when not recognised
-