Skip to content

Commit

Permalink
Made redis version configurable for IBM Bluemix RedisCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
cwjohan committed Oct 31, 2014
1 parent a77cba4 commit a3f754e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/connStrategyBlueMixRedisCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ ConnStrategyCustom = (function() {
function ConnStrategyCustom() {}

ConnStrategyCustom.prototype.getClient = function(config) {
var credentials, env, redisHost, redisOptions, redisPort;
var credentials, env, redisHost, redisOptions, redisPort, redisVersion;
this.config = config;
if (process.env.VCAP_SERVICES) {
env = JSON.parse(process.env.VCAP_SERVICES);
credentials = env['redis-2.6'][0].credentials;
redisVersion = this.config.redis_version || 'redis-2.6';
credentials = env[redisVersion][0].credentials;
redisOptions = this.config.redis_options;
this.client = redis.createClient(credentials.port, credentials.host, redisOptions);
if (credentials.password) {
Expand Down
3 changes: 2 additions & 1 deletion sample-configs/redis-queue-config-bluemix-redis-cloud.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"verbose": false,
"verbose": true,
"redis_provider": {
"type": "BlueMixRedisCloud"
},
"redis_options": {
"redis_version": "redis-2.6",
"retry_max_delay": 2000
}
}
3 changes: 2 additions & 1 deletion src/connStrategyBlueMixRedisCloud.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class ConnStrategyCustom
getClient: (@config) ->
if process.env.VCAP_SERVICES
env = JSON.parse process.env.VCAP_SERVICES
credentials = env['redis-2.6'][0].credentials
redisVersion = @config.redis_version or 'redis-2.6'
credentials = env[redisVersion][0].credentials
redisOptions = @config.redis_options
@client = redis.createClient credentials.port, credentials.host, redisOptions
@client.auth credentials.password if credentials.password
Expand Down

0 comments on commit a3f754e

Please sign in to comment.