Class: ConfigurationService::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/configuration_service/base.rb

Overview

The configuration service API

See README for a summary of the service, including links to user stories.

It is recommended that consumers use a Factory to create and configure the service.

Instance Method Summary collapse

Constructor Details

#initialize(identifier, token, provider) ⇒ Base

Deprecated.

use ConfigurationService::Client instead

Creates a new configuration service API instance

Parameters:

  • identifier (String)

    the unique identity of some configuration data and its associated metadata. It might be the name of a service or service component. It might include an environment label (e.g. production, staging, etc.) For example:

    • billing.acme.com

    • billing-web1.acme.com

    • billing/production/web1

  • token (String)

    opaque string representing authority to access the configuration data and associated metadata. Interpretation of the token is provider-dependent; it is opaque to the API and client.

  • provider (Object)

    a configured service provider instance, to which requests will be delegated.



33
34
35
36
37
# File 'lib/configuration_service/base.rb', line 33

def initialize(identifier, token, provider)
  warn "[DEPRECATION] 'ConfigurationService::Base' is deprecated.  Please use 'ConfigurationService::Client'."
  @identifier = identifier
  @client = ConfigurationService::Client.new(token, provider)
end

Instance Method Details

#publish_configuraion(data, metadata = {}) ⇒ ConfigurationService::Configuration

Publishes configuration data and metadata

The metadata is decorated with the following keys:

  • “timestamp” - the current UTC time in ISO8601 format

  • “revision” - a UUID for this publication

Delegates the request to the configured provider. The provider may further decorate the metadata.

It is recommended that both the data and metadata dictionaries use strings as keys, and that values be limited to those that can be serialized to JSON.

Parameters:

  • data (Hash)

    dictionary of probably sensitive configuration data intended for an application, which providers are expected to secure

  • metadata (Hash) (defaults to: {})

    dictionary of data about the configuration data, which providers are not expected to secure

Returns:

Raises:



73
74
75
# File 'lib/configuration_service/base.rb', line 73

def publish_configuraion(data,  = {})
  @client.publish_configuration(@identifier, data,  = {})
end

#request_configurationConfigurationService::Configuration

Requests the configuration data and metadata

Delegates the request to the configured provider.

Returns:

Raises:



48
49
50
# File 'lib/configuration_service/base.rb', line 48

def request_configuration
  @client.request_configuration(@identifier) 
end