Kafka-node: async/await

Created on 20 Dec 2017  ·  7Comments  ·  Source: SOHU-Co/kafka-node

What time to support async / await?
Thanks!

question

Most helpful comment

Nope, but you can create a PR @LunaPg

All 7 comments

This library doesn't use promises and we need to support latest LTS so I would say at the earliest after node 6 leaves LTS.

@hyperlink Hi, if I want to use async/await, what can i do? Can I use blurbird promisify to promise this library?

@DanielWLam shouldn't be an issue to bluebird or utils.promisify to promisify callback style methods.

Promises are definitely supported natively in Node 6. I understand not using async/await yet but it would be nice to at least have the option for users to use async/await on promises returned by this library.

It works fine with blurbird .

Here is an example:
` var Promise = require("bluebird");
...
const kafkaProducer = new kafka.Producer(kafkaClient, producerOptions);
const kafkaProducerSend = Promise.promisify(kafkaProducer .send, {context: kafkaProducer });

async function yop() {
...
await kafkaProducerSend ([kafkaMessage]);
// Send is complete when you reach this point and there is no exception
}
`

Enjoy.

Does a async/await version is planed ?

Nope, but you can create a PR @LunaPg

Was this page helpful?
0 / 5 - 0 ratings