Add debug to MaxMind circuit breaker

This commit is contained in:
Colin McDonald 2016-07-10 13:12:01 -04:00
parent 6e4169c6ad
commit 752c2cae96
1 changed files with 14 additions and 2 deletions

View File

@ -8,11 +8,13 @@ import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.json.JsonObject;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import net.frozenorb.apiv3.APIv3;
import net.frozenorb.apiv3.maxmind.MaxMindResult;
import java.util.Base64;
@Slf4j
@UtilityClass
public class MaxMindUtils {
@ -50,11 +52,21 @@ public class MaxMindUtils {
}
});
response.exceptionHandler(future::fail);
response.exceptionHandler((error) -> {
log.error("Got failure from MaxMind (" + ip + ")");
// we have to check !failed because the circuit breaker's timeout will mark us as failed already
if (!future.failed()) {
future.fail(error);
}
});
})
.putHeader("Authorization", authHeader)
.end();
}, (ignored) -> null).setHandler((result) -> { // The (ignored) -> null section is our fallback, which just returns null (when the breaker is open)
}, (ignored) -> {
log.error("Defaulting to failed MaxMind response (open breaker) (" + ip + ")");
return null;
}).setHandler((result) -> { // The (ignored) -> null section is our fallback, which just returns null (when the breaker is open)
if (result.failed()) {
callback.onResult(null, result.cause());
} else {