Blizzard / Blizzard/node-rdkafka

Proposal: Implement transformation middleware

Open
#124 10 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
2.2k
Forks
403
PR merge metrics
No merged PRs in 30d

Description

When implementing [kafka-avro](https://github.com/waldophotos/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:

```js
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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.