Open
Description
When implementing kafka-avro I resorted to hacking node-rdkafka
so I could intercept Produced and Consumed messages and encode or decode them using the appropriate avro schema.
I wanted to know if I put the effort to design and spec with your approval and implement a middleware transformation pattern for all Producing and Consuming methods, if you would accept such a pull request.
The idea is to provide a method for end-users or libraries to be able to transform a message before it will be actually produced or consumed. Something like:
consumer.transform(function(message) {
message.id = message.uuid;
return message;
});
The transform()
methods would accept multiple calls and would serially store the middleware to be consecutively executed. It could also be asynchronous if the value returned is a promise.
What do you think?