diff options
author | Taras Voinarovskiy <voyn1991@gmail.com> | 2017-08-25 09:38:27 +0000 |
---|---|---|
committer | Taras Voinarovskiy <voyn1991@gmail.com> | 2017-10-24 15:12:11 +0000 |
commit | 3af66bc542efff3f7010bec18b72d844e09488c4 (patch) | |
tree | a20623631b36230c9425b08ee95b85afbc9a9455 /kafka/record/abc.py | |
parent | e06af5343a55cf8d03e32a645ee970d872cb9ba0 (diff) | |
download | kafka-python-v2_records.tar.gz |
Add DefaultRecordBatch implementation aka V2 message format parser/builder.v2_records
Added bytecode optimization for varint and append/read_msg functions. Mostly based on avoiding LOAD_GLOBAL calls.
Diffstat (limited to 'kafka/record/abc.py')
-rw-r--r-- | kafka/record/abc.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/kafka/record/abc.py b/kafka/record/abc.py index 8a27276..83121c6 100644 --- a/kafka/record/abc.py +++ b/kafka/record/abc.py @@ -36,12 +36,18 @@ class ABCRecord(object): be the checksum for v0 and v1 and None for v2 and above. """ + @abc.abstractproperty + def headers(self): + """ If supported by version list of key-value tuples, or empty list if + not supported by format. + """ + class ABCRecordBatchBuilder(object): __metaclass__ = abc.ABCMeta @abc.abstractmethod - def append(self, offset, timestamp, key, value): + def append(self, offset, timestamp, key, value, headers=None): """ Writes record to internal buffer. Arguments: @@ -51,6 +57,8 @@ class ABCRecordBatchBuilder(object): set to current time. key (bytes or None): Key of the record value (bytes or None): Value of the record + headers (List[Tuple[str, bytes]]): Headers of the record. Header + keys can not be ``None``. Returns: (bytes, int): Checksum of the written record (or None for v2 and |