narcisoguillen / kafka-node-avro

ISC License
26 stars 13 forks source link

send method ignores timetamp field #15

Closed alfamegaxq closed 4 years ago

alfamegaxq commented 4 years ago

As in documentation of the send method parameters:

timestamp : Date.now() // <-- defaults to Date.now() (only available with kafka v0.10 and KafkaClient only)

kafka-node producer could take advantage of this timestamp parameter as we can see in kafka-node/lib/baseProducer.js return new Message(0, 0, p.key, message, p.timestamp || Date.now());

But when I pass timestamp to kafka-node-avro it is ignored and default Date.now() is used

             client.send({
                        topic: 'my-topic',
                        key: 123,
                        timestamp: 1578400460000, // this parameter ignored
                        messages: {
                            data: 'my-data',
                            timestamp: 1578400460000,
                            action: 'my-data'
                        }}); 

This field shouldn't be ignored.

alfamegaxq commented 4 years ago

I have created a pull request for this issue. Please take a look: https://github.com/narcisoguillen/kafka-node-avro/pull/16

narcisoguillen commented 4 years ago

Hey thanks for helping making kafka-node-avro better

narcisoguillen commented 4 years ago

I just add a change so it applies to any other field being sent , such us partition or attributes