diff options
author | Mark Roberts <markroberts@kixeye.com> | 2014-02-25 01:06:17 -0800 |
---|---|---|
committer | Mark Roberts <markroberts@kixeye.com> | 2014-02-25 11:26:06 -0800 |
commit | 9732ed1670ef0739956900df37c0c77699628ec7 (patch) | |
tree | 641572cdbd91dcaf60cd42723b46bb2c6f626d32 /kafka/common.py | |
parent | ee7e86ea712de0a0390e64752c5cf9180c1681b5 (diff) | |
download | kafka-python-9732ed1670ef0739956900df37c0c77699628ec7.tar.gz |
Minor refactor in conn.py, update version in __init__.py, add ErrorString
Diffstat (limited to 'kafka/common.py')
-rw-r--r-- | kafka/common.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/kafka/common.py b/kafka/common.py index c0a1a6a..583bb32 100644 --- a/kafka/common.py +++ b/kafka/common.py @@ -48,22 +48,28 @@ Message = namedtuple("Message", ["magic", "attributes", "key", "value"]) TopicAndPartition = namedtuple("TopicAndPartition", ["topic", "partition"]) +ErrorStrings = { + -1 : 'UNKNOWN', + 0 : 'NO_ERROR', + 1 : 'OFFSET_OUT_OF_RANGE', + 2 : 'INVALID_MESSAGE', + 3 : 'UNKNOWN_TOPIC_OR_PARTITON', + 4 : 'INVALID_FETCH_SIZE', + 5 : 'LEADER_NOT_AVAILABLE', + 6 : 'NOT_LEADER_FOR_PARTITION', + 7 : 'REQUEST_TIMED_OUT', + 8 : 'BROKER_NOT_AVAILABLE', + 9 : 'REPLICA_NOT_AVAILABLE', + 10 : 'MESSAGE_SIZE_TO_LARGE', + 11 : 'STALE_CONTROLLER_EPOCH', + 12 : 'OFFSET_METADATA_TOO_LARGE', +} + class ErrorMapping(object): - # Many of these are not actually used by the client - UNKNOWN = -1 - NO_ERROR = 0 - OFFSET_OUT_OF_RANGE = 1 - INVALID_MESSAGE = 2 - UNKNOWN_TOPIC_OR_PARTITON = 3 - INVALID_FETCH_SIZE = 4 - LEADER_NOT_AVAILABLE = 5 - NOT_LEADER_FOR_PARTITION = 6 - REQUEST_TIMED_OUT = 7 - BROKER_NOT_AVAILABLE = 8 - REPLICA_NOT_AVAILABLE = 9 - MESSAGE_SIZE_TO_LARGE = 10 - STALE_CONTROLLER_EPOCH = 11 - OFFSET_METADATA_TOO_LARGE = 12 + pass + +for k, v in ErrorStrings.items(): + setattr(ErrorMapping, v, k) ################# # Exceptions # |