-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add header support for kafka #955
Add header support for kafka #955
Conversation
looks good to me. @Steveb-p wdyt? |
I get the following (I guess) non-related error running the functional tests:
|
I was sure I did open a PR earlier with it: #880. Closed it since a lot has changed. However, I'd suggest getting the part with backward compatibility ported here? // Merge headers passed from Kafka with possible earlier serialized payload headers. Prefer Kafka's.
// Note: Requires phprdkafka >= 3.1.0
if (isset($kafkaMessage->headers)) {
$message->setHeaders(array_merge($message->getHeaders(), $kafkaMessage->headers));
} This way messages produced by earlier versions of I'll give it a look after work, but it should be fine :) |
So should I just copy over the code from your closed PR into this PR? Do we still need the segfault check? // Note: Topic::producev method exists in phprdkafka > 3.1.0
// Headers in payload are maintained for backwards compatibility with apps that might run on lower phprdkafka version
if (method_exists($topic, 'producev')) {
// Phprdkafka <= 3.1.0 will fail calling `producev` on librdkafka 1.0.0 causing segfault
if (version_compare(RdKafkaContext::getLibrdKafkaVersion(), '1.0.0', '>=')
&& version_compare(phpversion('rdkafka'), '3.1.0', '<=')) {
trigger_error('Phprdkafka < 3.1.0 is incompatible with librdkafka 1.0.0 when calling `producev`', E_USER_WARNING);
}
$topic->producev($partition, 0 /* must be 0 */, $payload, $key, $message->getHeaders());
} else {
$topic->produce($partition, 0 /* must be 0 */, $payload, $key);
} |
Yes actually. That would result in still allowing to work with lower phprdkafka versions, while using the new My original code should probably be changed to throw an |
@Steveb-p how about dropping to produce and trigger a PHP warning in the 3.1.0/1.0.0 case? |
|
@TiMESPLiNTER would you mind adding as well? It would provide cross-compatibility with earlier versions (which might actually be important since Kafka can store all historical messages, right? 😄 ) And the inclusion of that code for |
This code is currently already in master from what I see. Just the producing functionality is currently missing header support. |
@makasim IMO it's ready. As usual I'm not merging it since you're the owner 😈 |
When is the next released planned (including this "bug fix")? |
@TiMESPLiNTER until @makasim creates a new version (which should be soon™) you can use this functionality of composer to force it to use your fork:
So, in your case it might be: {
"repositories": [
{
"type": "vcs",
"url": "https://github.com/TiMESPLIiNTER/enqueue/rdkafka"
}
],
"require": {
"enqueue/rdkafka": "^0.9.13 | dev->>BRANCH-NAME<<"
}
} Adding |
Ths fix already in enqueue/rdkafka, you require dev version for now. I'll do release when I have time |
Okay, just was wondering if something is planned. All good I'll use |
This bumps the dependency on rdkafka extension from version
3.0.3
to3.1.0
.