Module: ConfigurationService::Factory::EnvironmentContextBackwardCompatibility
- Included in:
- EnvironmentContext
- Defined in:
- lib/configuration_service/factory/environment_context_backward_compatibility.rb
Overview
Support EnvironmentContext‘s deprecated use as a factory
New code should use ConfigurationService::Factory instead.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#create ⇒ ConfigurationService::Client
deprecated
Deprecated.
Use ConfigurationService::Factory instead.
Instance Method Details
#create ⇒ ConfigurationService::Client
Use ConfigurationService::Factory instead.
Create a configuration service bootstrapped with environmental configuration
The environment is scanned for ConfigurationService::Factory::EnvironmentContext#prefix matches, within which the following variables are used:
- IDENTIFIER
-
the unique identity of the configuration data (see Client#initialize)
- TOKEN
-
authorization token for the identified configuration data (see Client#initialize)
- PROVIDER
-
the unique identity of the service provider (see ProviderRegistry)
- PROVIDER_*
-
configuration options for the service provider (see service provider documentation)
On JRuby, system properties are also scanned. Where a system property and environment variable of the same name exist, the environment variable is preferred.
The service provider class is fetched from the ProviderRegistry using PROVIDER
. A service provider instance is then constructed with a dictionary of the PROVIDER_*
variables, in which the keys are the name of the variable without PROVIDER_
, downcased and intern’d.
Then a service Client is constructed with the IDENTIFIER
, TOKEN
and service provider instance.
And finally, the environment is scrubbed of the variables used, to protect them from accidental exposure (e.g. in an exception handler that prints the environment). On JRuby, system properties are scrubbed of variables used as well, regardless of whether they were overridden by environment variables.
48 49 50 51 |
# File 'lib/configuration_service/factory/environment_context_backward_compatibility.rb', line 48 def create $stderr.puts "warning: ConfigurationService::Factory::EnvironmentContext#create is deprecated: use ConfigurationService::Factory instead" ConfigurationService::Factory.create_client(self) end |