Module: ConfigurationService::Factory
- Defined in:
- lib/configuration_service/factory.rb,
lib/configuration_service/factory/context.rb,
lib/configuration_service/factory/yaml_file_context.rb,
lib/configuration_service/factory/environment_context.rb,
lib/configuration_service/factory/context/symbolic_access_wrapper.rb,
lib/configuration_service/factory/environment_context_backward_compatibility.rb
Overview
A factory for creating a configuration service client
Defined Under Namespace
Modules: EnvironmentContextBackwardCompatibility Classes: Context, EnvironmentContext, YamlFileContext
Class Method Summary collapse
-
.create_admin_client(context = EnvironmentContext.new) ⇒ ConfigurationService::AdminClient
Create a configuration service admin client.
-
.create_client(context = EnvironmentContext.new) ⇒ ConfigurationService::Base
Create a configuration service client.
Class Method Details
.create_admin_client(context = EnvironmentContext.new) ⇒ ConfigurationService::AdminClient
Create a configuration service admin client
When the context
is a Hash, it is wrapped in a Context, which does not scrub sources after the configuration service client is created. For this reason, the process ENV
should never be given as the context
; rather give no context
, so that the default EnvironmentContext will be used to safely scrub the process ENV
and (on JRuby) system properties after the configuration service client is created.
Because the AdminClient operates over multiple configuration identifiers, it does not require an identifier
property from the context.
83 84 85 86 87 88 89 |
# File 'lib/configuration_service/factory.rb', line 83 def self.create_admin_client(context = EnvironmentContext.new) context = Context.new(context) if context.is_a?(Hash) provider = create_provider(context) ConfigurationService::AdminClient.new(context.token, provider) ensure context.scrub! end |
.create_client(context = EnvironmentContext.new) ⇒ ConfigurationService::Base
Create a configuration service client
When the context
is a Hash, it is wrapped in a Context, which does not scrub sources after the configuration service client is created. For this reason, the process ENV
should never be given as the context
; rather give no context
, so that the default EnvironmentContext will be used to safely scrub the process ENV
and (on JRuby) system properties after the configuration service client is created.
The context must provide an identifier
property.
60 61 62 63 64 65 66 |
# File 'lib/configuration_service/factory.rb', line 60 def self.create_client(context = EnvironmentContext.new) context = Context.new(context) if context.is_a?(Hash) provider = create_provider(context) ConfigurationService::Base.new(context.identifier, context.token, provider) ensure context.scrub! end |