Skip to content
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

Adjust KafkaConsumerMessage to always return an array for headers #63

Open
antonkomarev opened this issue May 27, 2021 · 6 comments
Open
Milestone

Comments

@antonkomarev
Copy link

Jobcloud\Kafka\Message\KafkaConsumerMessage right now has this signature:

public function __construct(
    string $topicName,
    int $partition,
    int $offset,
    int $timestamp,
    $key,
    $body,
    ?array $headers
) {

Is there any reason why headers is nullable? What are the use cases for null value?

I see that headers are casting to array right now:

return new KafkaConsumerMessage(
    (string) $message->topic_name,
    (int) $message->partition,
    (int) $message->offset,
    (int) $message->timestamp,
    $message->key,
    $message->payload,
    (array) $message->headers
);
@nick-zh
Copy link
Contributor

nick-zh commented May 27, 2021

@antonkomarev not everybody leverages the usage of headers, so they might be null on Kafka side

@antonkomarev
Copy link
Author

antonkomarev commented May 27, 2021

Okay, but you are casting them to array, why KafkaConsumerMessage headers param is nullable then? As for me empty array means that there is no headers as well as null value

@nick-zh
Copy link
Contributor

nick-zh commented May 27, 2021

@antonkomarev is a good point, i don't remember anymore why we cast it. Maybe we always wanted to return an array but forgot to change the method signature. I'll need to check ✌️

@nick-zh
Copy link
Contributor

nick-zh commented Jun 2, 2021

@antonkomarev sry for the delay, so i definitely think, this was an oversight on our side. I agree that we should fix that, but since either way (adjusting the interface or removing the array cast) will break the behaviour, we'll need to put it into the next major.

@nick-zh nick-zh changed the title Should headers parameter in KafkaConsumerMessage be nullable? Adjust KafkaConsumerMessage to always return an array Jun 2, 2021
@nick-zh nick-zh added this to the v2.0.0 milestone Jun 2, 2021
@antonkomarev
Copy link
Author

You are right, that's BC break. Will look forward to it!

@nick-zh
Copy link
Contributor

nick-zh commented Jun 2, 2021

Thanks again for that input btw 🙏

@nick-zh nick-zh changed the title Adjust KafkaConsumerMessage to always return an array Adjust KafkaConsumerMessage to always return an array for headers Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants