From 752c2cae96e68bc0002bc2513346cd456519b28a Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Sun, 10 Jul 2016 13:12:01 -0400 Subject: [PATCH] Add debug to MaxMind circuit breaker --- .../net/frozenorb/apiv3/util/MaxMindUtils.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/frozenorb/apiv3/util/MaxMindUtils.java b/src/main/java/net/frozenorb/apiv3/util/MaxMindUtils.java index 0f73216..13bb63f 100644 --- a/src/main/java/net/frozenorb/apiv3/util/MaxMindUtils.java +++ b/src/main/java/net/frozenorb/apiv3/util/MaxMindUtils.java @@ -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 {