fgeller / kt

Kafka command line tool that likes JSON
MIT License
950 stars 100 forks source link

Partitioner argument is not read #71

Closed vmaurin closed 6 years ago

vmaurin commented 6 years ago

The -partitioner option for producer doesn't seem to have any effect. It sounds it is not passed properly to the cmd object in this section of the code

cmd.batch = args.batch
cmd.timeout = args.timeout
cmd.verbose = args.verbose
cmd.pretty = args.pretty
cmd.literal = args.literal
cmd.partition = int32(args.partition)
cmd.version = kafkaVersion(args.version)
cmd.bufferSize = args.bufferSize
vmaurin commented 6 years ago

Also, I have tried to force the partitioner and I am not getting the same partition as the kafka java driver for example

fgeller commented 6 years ago

hi @vmaurin thanks for the feedback and thanks for the hint! i just pushed a commit to pass the partitioner argument along, would you mind testing it? to get the latest version:

go get -u github.com/fgeller/kt
vmaurin commented 6 years ago

Thx for the quick fix. Partitioner option is taken in account now

For the mismatch with java partitioner, it seems it is using a different hashing algorithm https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/DefaultPartitioner.java

Not having the same behavior is not really a "bug", but it will end with unexpected result if both kt and a standard kafka producer are used to produce on the same topic (no proper log compaction, unordered read for the same key)

fgeller commented 6 years ago

closing this for now, will document more details on #74 for the partitioner issue