diff options
author | David Arthur <mumrah@gmail.com> | 2013-09-24 21:18:55 -0400 |
---|---|---|
committer | David Arthur <mumrah@gmail.com> | 2013-09-24 21:20:00 -0400 |
commit | c0d2cac66940bf477c008e65c9d2bbcd79f030a0 (patch) | |
tree | ee5dc075a7d9ec86633bf4e0076a522e70da0ab4 | |
parent | 9af7b817c17a8d8c08e60607f117c8ac46668eda (diff) | |
download | kafka-python-c0d2cac66940bf477c008e65c9d2bbcd79f030a0.tar.gz |
Fix #44 Add missing exception classv0.8.0
Also move the exceptions to common instead of util
-rw-r--r-- | CHANGES.md | 2 | ||||
-rw-r--r-- | kafka/common.py | 16 | ||||
-rw-r--r-- | kafka/consumer.py | 7 | ||||
-rw-r--r-- | kafka/protocol.py | 6 | ||||
-rw-r--r-- | kafka/queue.py | 2 | ||||
-rw-r--r-- | kafka/util.py | 9 |
6 files changed, 25 insertions, 17 deletions
@@ -5,3 +5,5 @@ * Adding fetch_size_bytes to SimpleConsumer constructor to allow for user-configurable fetch sizes * Allow SimpleConsumer to automatically increase the fetch size if a partial message is read and no other messages were read during that fetch request. The increase factor is 1.5 + +* Exception classes moved to kafka.common diff --git a/kafka/common.py b/kafka/common.py index 9aab8fc..0a1d314 100644 --- a/kafka/common.py +++ b/kafka/common.py @@ -64,3 +64,19 @@ class ErrorMapping(object): MESSAGE_SIZE_TO_LARGE = 10 STALE_CONTROLLER_EPOCH = 11 OFFSET_METADATA_TOO_LARGE = 12 + +################# +# Exceptions # +################# + +class BufferUnderflowError(Exception): + pass + +class ChecksumError(Exception): + pass + +class ConsumerFetchSizeTooSmall(Exception): + pass + +class ConsumerNoMoreData(Exception): + pass diff --git a/kafka/consumer.py b/kafka/consumer.py index 6ac13c7..c338337 100644 --- a/kafka/consumer.py +++ b/kafka/consumer.py @@ -8,12 +8,11 @@ from Queue import Empty from kafka.common import ( ErrorMapping, FetchRequest, - OffsetRequest, OffsetFetchRequest, OffsetCommitRequest + OffsetRequest, OffsetFetchRequest, OffsetCommitRequest, + ConsumerFetchSizeTooSmall, ConsumerNoMoreData ) -from kafka.util import ( - ReentrantTimer, ConsumerFetchSizeTooSmall -) +from kafka.util import ReentrantTimer log = logging.getLogger("kafka") diff --git a/kafka/protocol.py b/kafka/protocol.py index f985479..c2b017e 100644 --- a/kafka/protocol.py +++ b/kafka/protocol.py @@ -8,12 +8,12 @@ from kafka.codec import ( from kafka.common import ( BrokerMetadata, PartitionMetadata, Message, OffsetAndMessage, ProduceResponse, FetchResponse, OffsetResponse, - OffsetCommitResponse, OffsetFetchResponse + OffsetCommitResponse, OffsetFetchResponse, + BufferUnderflowError, ChecksumError, ConsumerFetchSizeTooSmall ) from kafka.util import ( read_short_string, read_int_string, relative_unpack, - write_short_string, write_int_string, group_by_topic_and_partition, - BufferUnderflowError, ChecksumError, ConsumerFetchSizeTooSmall + write_short_string, write_int_string, group_by_topic_and_partition ) log = logging.getLogger("kafka") diff --git a/kafka/queue.py b/kafka/queue.py index 3bd7dca..41f1c31 100644 --- a/kafka/queue.py +++ b/kafka/queue.py @@ -4,7 +4,7 @@ from multiprocessing import Process, Queue, Event from Queue import Empty import time -from .client import KafkaClient, FetchRequest, ProduceRequest +from kafka.client import KafkaClient, FetchRequest, ProduceRequest log = logging.getLogger("kafka") diff --git a/kafka/util.py b/kafka/util.py index bdda7ed..d580ad7 100644 --- a/kafka/util.py +++ b/kafka/util.py @@ -66,15 +66,6 @@ def group_by_topic_and_partition(tuples): return out -class BufferUnderflowError(Exception): - pass - - -class ChecksumError(Exception): - pass - -class ConsumerFetchSizeTooSmall(Exception): - pass class ReentrantTimer(object): """ |