From 3ca04e25fda6b936ba73a5778c0e8a040ce71584 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 13 Oct 2014 13:15:48 +0100 Subject: [PATCH] add 1 second timeout to geoiplookup response times generally seem to be around 0.05s from our servers --- services/web/app/coffee/infrastructure/GeoIpLookup.coffee | 1 + .../UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/services/web/app/coffee/infrastructure/GeoIpLookup.coffee b/services/web/app/coffee/infrastructure/GeoIpLookup.coffee index a5a09b3249..0682940818 100644 --- a/services/web/app/coffee/infrastructure/GeoIpLookup.coffee +++ b/services/web/app/coffee/infrastructure/GeoIpLookup.coffee @@ -25,6 +25,7 @@ module.exports = GeoIpLookup = opts = url: "#{settings.apis.geoIpLookup.url}/#{ip}" + timeout: 1000 request.get opts, (err, ipDetails)-> callback(err, ipDetails) diff --git a/services/web/test/UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee b/services/web/test/UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee index d442ab6d7b..680f942df0 100644 --- a/services/web/test/UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee +++ b/services/web/test/UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee @@ -41,7 +41,7 @@ describe "GeoIpLookup", -> it "should request the details using the ip", (done)-> @GeoIpLookup.getDetails @ipAddress, (err)=> - @request.get.calledWith(url:@settings.apis.geoIpLookup.url+"/"+@ipAddress).should.equal true + @request.get.calledWith({url:@settings.apis.geoIpLookup.url+"/"+@ipAddress, timeout:1000}).should.equal true done() it "should return the ip details", (done)-> @@ -51,7 +51,7 @@ describe "GeoIpLookup", -> it "should take the first ip in the string", (done)-> @GeoIpLookup.getDetails " #{@ipAddress} 456.312.452.102 432.433.888.234", (err)=> - @request.get.calledWith(url:@settings.apis.geoIpLookup.url+"/"+@ipAddress).should.equal true + @request.get.calledWith({url:@settings.apis.geoIpLookup.url+"/"+@ipAddress, timeout:1000}).should.equal true done() describe "getCurrencyCode", ->