35 |
if (conf.useGoogle == false) |
if (conf.useGoogle == false) |
36 |
return null; |
return null; |
37 |
|
|
|
limiter.acquire(); |
|
38 |
|
|
39 |
result.google = true; |
result.google = true; |
40 |
|
|
41 |
try { |
try { |
42 |
GoogleInvocation wrapper = new GoogleInvocation( conf, request.postnr, request.vejnavn ); |
GoogleInvocation wrapper = new GoogleInvocation( limiter, conf, request.postnr, request.vejnavn ); |
43 |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("google"); |
CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("google"); |
44 |
|
|
45 |
|
|
57 |
ServiceConfig conf; |
ServiceConfig conf; |
58 |
int postnr; |
int postnr; |
59 |
String vejnavn; |
String vejnavn; |
60 |
|
RateLimiter limiter; |
61 |
|
|
62 |
public GoogleInvocation(ServiceConfig conf, int postnr, String vejnavn) { |
public GoogleInvocation(RateLimiter limiter, ServiceConfig conf, int postnr, String vejnavn) { |
63 |
|
this.limiter = limiter; |
64 |
this.conf = conf; |
this.conf = conf; |
65 |
this.postnr= postnr; |
this.postnr= postnr; |
66 |
this.vejnavn = vejnavn; |
this.vejnavn = vejnavn; |
69 |
|
|
70 |
@Override |
@Override |
71 |
public String proceed() throws Exception { |
public String proceed() throws Exception { |
72 |
|
|
73 |
|
limiter.acquire(); |
74 |
|
|
75 |
final Geocoder geocoder; |
final Geocoder geocoder; |
76 |
if ( conf.googleApiKey != null ) { |
if ( conf.googleApiKey != null ) { |