reliable-get
Advanced tools
Comparing version 0.1.25 to 0.1.26
12
index.js
@@ -68,6 +68,6 @@ 'use strict'; | ||
res.content = content; | ||
res.timing = Date.now() - start; | ||
cb(null, res); | ||
var timing = Date.now() - start; | ||
self.emit('log', 'debug', 'OK ' + options.url, {tracer:options.tracer, responseTime: timing, type:options.type}); | ||
self.emit('stat', 'timing', options.statsdKey + '.responseTime', timing); | ||
self.emit('log', 'debug', 'OK ' + options.url, {tracer:options.tracer, responseTime: res.timing, type:options.type}); | ||
self.emit('stat', 'timing', options.statsdKey + '.responseTime', res.timing); | ||
}); | ||
@@ -82,3 +82,3 @@ | ||
res.headers['cache-control'] = 'no-store'; | ||
next(null, {statusCode: res.statusCode, content: res.content, headers: res.headers}); | ||
next(null, {statusCode: res.statusCode, content: res.content, headers: res.headers, timing: res.timing}); | ||
}); | ||
@@ -96,3 +96,3 @@ } | ||
self.emit('stat', 'increment', options.statsdKey + '.cacheHit'); | ||
next(null, {statusCode: 200, content: cacheData.content, headers: cacheData.headers}); | ||
next(null, {statusCode: 200, content: cacheData.content, headers: cacheData.headers, timing: timing}); | ||
return; | ||
@@ -132,3 +132,3 @@ } | ||
cache.set(options.cacheKey, {content: res.content, headers: res.headers, options: options}, options.cacheTTL, function() { | ||
next(null, {statusCode: 200, content: res.content, headers:res.headers}); | ||
next(null, {statusCode: 200, content: res.content, headers:res.headers, timing: res.timing}); | ||
self.emit('log','debug', 'CACHE SET for key: ' + options.cacheKey + ' @ TTL: ' + options.cacheTTL,{tracer:options.tracer,type:options.type}); | ||
@@ -135,0 +135,0 @@ }); |
{ | ||
"name": "reliable-get", | ||
"version": "0.1.25", | ||
"version": "0.1.26", | ||
"description": "A circuit breaker and cached wrapper for GET requests (enables reliable external service interaction).", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
33627618