summaryrefslogtreecommitdiff
path: root/kafka/common.py
diff options
context:
space:
mode:
authorViktor Shlapakov <vshlapakov@gmail.com>2015-04-21 17:47:55 +0300
committerViktor Shlapakov <vshlapakov@gmail.com>2015-06-03 11:22:48 +0300
commitb31114520a15477da7ad660765a0240b6f348944 (patch)
tree29ba4678efeb31aafe4b99bfe6c158cf53a4526c /kafka/common.py
parent0e0f794802076db34e8e4dc597c38237e88f4b34 (diff)
downloadkafka-python-b31114520a15477da7ad660765a0240b6f348944.tar.gz
Clean and simplify retry logic
Diffstat (limited to 'kafka/common.py')
-rw-r--r--kafka/common.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/kafka/common.py b/kafka/common.py
index cbb4013..50f8a77 100644
--- a/kafka/common.py
+++ b/kafka/common.py
@@ -82,6 +82,8 @@ RetryOptions = namedtuple("RetryOptions",
["limit", "backoff_ms", "retry_on_timeouts"])
+
+
#################
# Exceptions #
#################
@@ -228,3 +230,18 @@ def check_error(response):
if response.error:
error_class = kafka_errors.get(response.error, UnknownError)
raise error_class(response)
+
+
+RETRY_BACKOFF_ERROR_TYPES = (
+ KafkaUnavailableError, LeaderNotAvailableError,
+ ConnectionError, FailedPayloadsError
+)
+
+
+RETRY_REFRESH_ERROR_TYPES = (
+ NotLeaderForPartitionError, UnknownTopicOrPartitionError,
+ LeaderNotAvailableError, ConnectionError
+)
+
+
+RETRY_ERROR_TYPES = list(set(RETRY_BACKOFF_ERROR_TYPES + RETRY_REFRESH_ERROR_TYPES))