Class VersionedRedisConfigurationSource

All Implemented Interfaces:
ConfigurableConfigurationSource<VersionedRedisConfigurationSource.VersionedRedisConfigurationQuery,VersionedRedisConfigurationSource.VersionedRedisExecutableConfigurationQuery,VersionedRedisConfigurationSource.VersionedRedisListConfigurationQuery,VersionedRedisConfigurationSource.VersionedRedisConfigurationUpdate,VersionedRedisConfigurationSource.VersionedRedisExecutableConfigurationUpdate>, ConfigurationSource<VersionedRedisConfigurationSource.VersionedRedisConfigurationQuery,VersionedRedisConfigurationSource.VersionedRedisExecutableConfigurationQuery,VersionedRedisConfigurationSource.VersionedRedisListConfigurationQuery>, DefaultableConfigurationSource<VersionedRedisConfigurationSource.VersionedRedisConfigurationQuery,VersionedRedisConfigurationSource.VersionedRedisExecutableConfigurationQuery,VersionedRedisConfigurationSource.VersionedRedisListConfigurationQuery,VersionedRedisConfigurationSource>

A configurable configuration source that stores and looks up properties in a Redis data store.

This implementation supports basic versioning which allows to set multiple properties and activate or revert them atomically.

Properties can be viewed in a tree of properties whose nodes correspond to parameters in natural order, a global revision is defined at the root of the tree and finer revisions can also be created in child nodes to version particular branches.

Particular care must be taken when deciding to version a specific branch, a property can only be versioned once which is the case when versioned property sets are disjointed. More specifically, a given property can't be versioned twice which might happen when the configuration is activated with different overlapping sets of parameters. An exception is normally thrown when such situation is detected. On the other hand, it is quite possible to version nested branches.

For instance, the following setup is most likely to fail if properties can be defined with both environment="production" and zone="eu" parameters:

  • []: global tree
  • [environment="production"]: production environment tree
  • [zone="eu"]: eu zone tree

While the following setup will work just fine:

  • []: global tree
  • [environment="production"]: production environment tree
  • [environment="production", zone="eu"]: eu zone tree

Properties are set for the working revision corresponding to their parameters. The working revision is activated using the activate(Parameter[]) method, the activate(int, Parameter[]) is used to activate a specific revision.

A typical workflow to set properties is:


 VersionedRedisConfigurationSource source = ...;
 source
     .set("db.url", "jdbc:oracle:thin:@dev.db.server:1521:sid").withParameters("env", "dev").and()
     .set("db.url", "jdbc:oracle:thin:@prod_eu.db.server:1521:sid").withParameters("env", "prod", "zone", "eu").and()
     .set("db.url", "jdbc:oracle:thin:@prod_us.db.server:1521:sid").withParameters("env", "prod", "zone", "us")
     .execute()
     .blockLast();
 
 // Activate working revision globally
 source.activate().block();
 
 // Activate working revision for dev environment and prod environment independently
 source.activate("env", "dev").block();
 source.activate("env", "prod").block();
 

This configuration source stored three types of entries:

  • Configuration properties as a sorted set with key of the form: keyPrefix ":V:PROP:" propertyName "[" [ key "=" value [ "," key "=" value ]* "]".
  • Configuration metadata as hashes with key of the form: keyPrefix ":V:META:" propertyName "[" [ key "=" value [ "," key "=" value ]* "]".
  • A configuration metadata control entry as a set with key of the form: keyPrefix ":V:META:CTRL".
Since:
1.0
Author:
Jeremy Kuhn
See Also: