-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix timestamp not passed to RecordMetadata #1273
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
test/test_producer.py
Outdated
retries=5, | ||
max_block_ms=10000, | ||
compression_type=compression, | ||
value_serializer=str.encode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're sending bytes below so no serializer needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy-paste)
@@ -484,3 +490,37 @@ def estimate_size_in_bytes(cls, magic, compression_type, key, value): | |||
cls.record_size(magic, key, value) | |||
) | |||
return cls.LOG_OVERHEAD + cls.record_size(magic, key, value) | |||
|
|||
|
|||
class LegacyRecordMetadata(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I am clearly missing something... What is the purpose of this class? It doesn't seem to do anything other than enforcing read-only on the attributes. Is there something else it does that I'm not realizing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's more or less as you said. It's just a class to store results of a function. I find this a bit more clean than namedtuple
when it comes to optimization. This is a hot part.
It's a more convenient way of returning several values from a function. Returning a tuple will require you to parse it every time, but returning either None
or an instance will only require a None check. See https://github.com/dpkp/kafka-python/pull/1273/files#diff-261f56705197d1ab9e6fca9249856556 and https://github.com/dpkp/kafka-python/pull/1273/files#diff-d98d7e54a13e15511c44d90e78f105e9R368.
Tried to fix #1270 and found, that it did not work properly in the first place. Was a bug in FutureRecordMetadata, that ignored timestamp=-1 being returned from the broker.
Also minor fixes include:
RecordMetadata
.checksum