Open sash opened 2 months ago
Hey @sash 👋
I believe your argument to withKey
should be just the uuid()
call. The \RdKafka\ProducerTopic::producev()
method accepts only null
or string
as parameter, that's why the withKey
method is type hinted with ?string
.
Hi @mateusjunges
The key will ultimately be encoded to string by the AVRO encoder, but when I set it I need it to be a complex structure so that avro will work on it to encode it.
Describe the bug The
Junges\Kafka\Contracts\ProducerMessage
definespublic function withKey(?string $key): ProducerMessage;
but when using avro we often want to pass more complex data to be encoded in avro. That is currently not possible because the type check fails.To Reproduce
fails with $key should be string or null, array given.
Expected behavior Allow assign of complex data to key that will later be convertable to avro.
Additional context Note that the consumer doent have this issue since
Junges\Kafka\Contracts\KafkaMessage
declarespublic function getKey(): mixed;