Commit 9aa7474f7ac865703a3d44b7902b9b9d39bebf08

Authored by Adhidarma Hadiwinoto
1 parent bb862b901c
Exists in master

make redis not mandatory

Showing 3 changed files with 10 additions and 0 deletions Side-by-side Diff

... ... @@ -326,6 +326,8 @@ function doRequestOrAdvice(task) {
326 326 }
327 327  
328 328 function publishTaskToRedis(task) {
  329 + if (!redisClient) return;
  330 +
329 331 try {
330 332 var key = 'kimochi.aaa_pull.gw:' + config.globals.gateway_name;
331 333  
... ... @@ -344,6 +346,8 @@ function getAaaTaskRedisKey(requestId) {
344 346 }
345 347  
346 348 function saveTaskToRedis(task) {
  349 + if (!redisClient) return;
  350 +
347 351 try {
348 352 var key = getAaaTaskRedisKey(task['requestId']);
349 353  
... ... @@ -613,6 +617,8 @@ function callbackReport(requestId, responseCode, message, retry) {
613 617 }
614 618  
615 619 function updateStockFromMessage(requestId, message) {
  620 + if (!redisClient) return;
  621 +
616 622 if (!config.globals.stock_regex || !config.globals.stock_regex_index) {
617 623 return;
618 624 }
... ... @@ -23,6 +23,8 @@ function init(options) {
23 23 }
24 24  
25 25 function _createRedisClient(host, port) {
  26 + if (!host || !port) return;
  27 +
26 28 try {
27 29 redisClient = redis.createClient(port, host);
28 30 logger.verbose('Common redis client created');
... ... @@ -9,6 +9,8 @@ var redisExpiredInSeconds = 3600*24*30;
9 9 var taskHistory = LRU({max: 20, maxAge: 1000 * 3600 * 2});
10 10  
11 11 function createRedisClient(host, port) {
  12 + if (!host || !port) return;
  13 +
12 14 try {
13 15 redisClient = redis.createClient(port, host);
14 16 logger.verbose(__filename + ': Redis client for task history created');