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

How to use $key for internal Kafka partitioning logic on producer #26

Open
mrdvt92 opened this issue Apr 24, 2020 · 1 comment
Open

Comments

@mrdvt92
Copy link

mrdvt92 commented Apr 24, 2020

I'm not a pro at C but it appears that we can pass a -1 as the partition and then the $key will go through the crc32 logic for automatic partitioning. Is that correct?

If so, can that be documented. Also supporting undef() would make for a better perl-ish API.

$err = $topic->produce($partition, $msgflags, $payload, $key);
$err = $topic->produce(-1, $msgflags, $payload, $key); #auto partition based on $key
$err = $topic->produce(undef(), $msgflags, $payload, $key); #future auto partition based on $key
@mrdvt92 mrdvt92 changed the title How to use $key for internal Kafka partitioning logic How to use $key for internal Kafka partitioning logic on producer Apr 24, 2020
@plicease
Copy link
Member

plicease commented Apr 25, 2020

$partition set to -1 is RD_KAFKA_PARTITION_UA: (unassigned) for automatic partitioning using the topic's partitioner function.
https://docs.confluent.io/2.0.0/clients/librdkafka/rdkafka_8h.html#a95e4f88cc907347eee16ff36ab58d10e

I think rather than documenting -1 or making undef map to -1, it would be better to add RD_KAFKA_PARTITION_UA as an exportable constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants