push-ioredis
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -9,3 +9,2 @@ var Redis = require('ioredis'); | ||
var RedisClusterMap = require('../lib/redisClusterMap'); | ||
var redisSharding = require('../config/redisSharding') | ||
@@ -15,3 +14,7 @@ var dictionary = {}; | ||
var RedisFailover = function(configFilePath) { | ||
var RedisFailover = function(configFilePath, redisShardingPath, env, clusterMapPath) { | ||
this.env = env; | ||
this.redisSharding = require(redisShardingPath); | ||
this.clusterMapPath = clusterMapPath; | ||
//console.log('redisSharding is ' + this.redisSharding); | ||
var config; | ||
@@ -58,5 +61,2 @@ if (!!configFilePath) { | ||
} | ||
//redis.dbsize(function(err, result) { | ||
// console.log('result = ' + result); | ||
//}); | ||
dictionary[obj[key]] = redis; | ||
@@ -71,13 +71,12 @@ } | ||
RedisFailover.prototype.createClient = function(environment) { | ||
var env = environment || 'drill'; | ||
var drillSharding = redisSharding[env]; | ||
RedisFailover.prototype.createClient = function() { | ||
var sharding = this.redisSharding[this.env]; | ||
//var redisFailover = new RedisFailover(); | ||
//redisFailover.createClient('../config/redisConfig.json'); | ||
var redisClusterMap = new RedisClusterMap(); | ||
//var redisProxy = new ClientProxy(redisFailover, drillSharding); | ||
redisProxy = new ClientProxy(this, drillSharding); | ||
var redisClusterMap = new RedisClusterMap(this.clusterMapPath); | ||
//var redisProxy = new ClientProxy(redisFailover, sharding); | ||
redisProxy = new ClientProxy(this, sharding); | ||
console.log(drillSharding['num']); | ||
console.log('sharding[num] = ' + sharding['num']); | ||
redisProxy.init(); | ||
@@ -84,0 +83,0 @@ redisProxy.setRedisClusterMap(redisClusterMap); |
@@ -1,2 +0,2 @@ | ||
var RedisClusterMap = function() { | ||
var RedisClusterMap = function(loadpath) { | ||
this.$id = "redisClusterMap"; | ||
@@ -6,2 +6,3 @@ this.clusterEnvMap = {}; | ||
this.clusterNodes = []; | ||
this.loadpath = loadpath; | ||
} | ||
@@ -12,4 +13,4 @@ | ||
if (!clusterMap) { | ||
var loadPath = '../config/' + env + '/clusterMap.json'; | ||
clusterMap = require(loadPath); | ||
var clusterLoadPath = this.loadpath || ('../config/' + env + '/clusterMap.json'); | ||
clusterMap = require(clusterLoadPath); | ||
@@ -16,0 +17,0 @@ this.loadClusterNodes(clusterMap); |
{ | ||
"name": "push-ioredis", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "use sentinel + ioredis + sharding logic to replace push-redis-failover", | ||
@@ -5,0 +5,0 @@ "main": "redisClient.js", |
@@ -10,4 +10,9 @@ var crypto = require('crypto'); | ||
var redisFailover = new RedisFailover('../config/redisConfig.json'); | ||
var failover = redisFailover.createClient('drill'); | ||
var redisConfigPath = '../config/redisConfig.json'; | ||
var redisShardingPath = '../config/redisSharding.json'; | ||
var env = 'drill'; | ||
var clusterMapPath = '../config/drill/clusterMap.json'; | ||
//var redisFailover = new RedisFailover(redisConfigPath, redisShardingPath, env, clusterMapPath); | ||
var redisFailover = new RedisFailover(redisConfigPath, redisShardingPath, env, null); | ||
var failover = redisFailover.createClient(); | ||
@@ -14,0 +19,0 @@ //var redisClusterMap = new RedisClusterMap(); |
@@ -6,5 +6,10 @@ var RedisFailover = require('../lib/redis-failover'); | ||
//redisFailover.createClient('../config/redisConfig.json'); | ||
var redisFailover = new RedisFailover('../config/redisConfig.json'); | ||
var failover = redisFailover.createClient('drill'); | ||
var redisConfigPath = '../config/redisConfig.json'; | ||
var redisShardingPath = '../config/redisSharding.json'; | ||
var env = 'drill'; | ||
var clusterMapPath = '../config/drill/clusterMap.json'; | ||
var redisFailover = new RedisFailover(redisConfigPath, redisShardingPath, env, clusterMapPath); | ||
var failover = redisFailover.createClient(); | ||
redisFailover.asyncTest(); | ||
@@ -11,0 +16,0 @@ |
var crypto = require('crypto'); | ||
var RedisClient = require('../index'); | ||
var RedisFailover = require('../index'); | ||
var redisClient = new RedisClient(); | ||
var failover = redisClient.createClient('drill'); | ||
var redisConfigPath = '../config/redisConfig.json'; | ||
var redisShardingPath = '../config/redisSharding.json'; | ||
var env = 'drill'; | ||
var clusterMapPath = '../config/drill/clusterMap.json'; | ||
var redisFailover = new RedisFailover(redisConfigPath, redisShardingPath, env, null); | ||
var failover = redisFailover.createClient(); | ||
console.log('this is testIndex'); | ||
@@ -8,0 +13,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
26862
12
781
6