@quantos/micro-request
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -19,10 +19,14 @@ "use strict"; | ||
let redisClient; | ||
if (process.env.REDIS_PORT && process.env.REDIS_HOST) { | ||
console.log('[@quantos/micro-request][Init redis client] Creating client on ' + process.env.REDIS_HOST + ':' + process.env.REDIS_PORT); | ||
redisClient = redis_1.default.createClient(Number.parseInt(process.env.REDIS_PORT), process.env.REDIS_HOST, { enable_offline_queue: false }); | ||
redisClient.on('error', (error) => { | ||
console.error('[@quantos/micro-request][Init redis client] ' + error); | ||
redisClient = null; | ||
}); | ||
function initRedisClient() { | ||
if (process.env.REDIS_PORT && process.env.REDIS_HOST) { | ||
console.log('[@quantos/micro-request][Init redis client] Creating client on ' + process.env.REDIS_HOST + ':' + process.env.REDIS_PORT); | ||
redisClient = redis_1.default.createClient(Number.parseInt(process.env.REDIS_PORT), process.env.REDIS_HOST, { enable_offline_queue: false }); | ||
redisClient.on('error', (error) => { | ||
console.error('[@quantos/micro-request][Init redis client] ' + error); | ||
redisClient = null; | ||
setTimeout(() => initRedisClient(), 10000); | ||
}); | ||
} | ||
} | ||
initRedisClient(); | ||
class RedisCache { | ||
@@ -29,0 +33,0 @@ static get(id, cachePrefix) { |
{ | ||
"name": "@quantos/micro-request", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Quantos http client with cache, retry and fallback mechanism", | ||
@@ -5,0 +5,0 @@ "author": "fabriziotognetto <info@quantos.it>", |
@@ -7,10 +7,15 @@ import { RedisValueHelper } from '@quantos/redis-helper'; | ||
let redisClient: redis.RedisClient; | ||
if (process.env.REDIS_PORT && process.env.REDIS_HOST) { | ||
console.log('[@quantos/micro-request][Init redis client] Creating client on ' + process.env.REDIS_HOST + ':' + process.env.REDIS_PORT); | ||
redisClient = redis.createClient(Number.parseInt(process.env.REDIS_PORT), process.env.REDIS_HOST, {enable_offline_queue: false}); | ||
redisClient.on('error', (error: any) => { | ||
console.error('[@quantos/micro-request][Init redis client] ' + error); | ||
redisClient = null; | ||
}); | ||
function initRedisClient(): void { | ||
if (process.env.REDIS_PORT && process.env.REDIS_HOST) { | ||
console.log('[@quantos/micro-request][Init redis client] Creating client on ' + process.env.REDIS_HOST + ':' + process.env.REDIS_PORT); | ||
redisClient = redis.createClient(Number.parseInt(process.env.REDIS_PORT), process.env.REDIS_HOST, {enable_offline_queue: false}); | ||
redisClient.on('error', (error: any) => { | ||
console.error('[@quantos/micro-request][Init redis client] ' + error); | ||
redisClient = null; | ||
setTimeout(() => initRedisClient(), 10000); | ||
}); | ||
} | ||
} | ||
initRedisClient(); | ||
@@ -17,0 +22,0 @@ export class RedisCache { |
Sorry, the diff of this file is not supported yet
35671
741