Conversation
@@ -0,0 +1,47 @@ | |||
linters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,57 @@ | |||
# Makefile based on https://gist.github.com/thomaspoignant/5b72d579bd5f311904d973652180c705 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
) | ||
|
||
replace github.com/grepplabs/kafka-proxy => github.com/smoya/kafka-proxy v0.2.9-0.20210623125118-a94cf71a065c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the replace directive in order to use my forked version of grepplabs/kafka-proxy
@@ -8,8 +8,11 @@ | |||
# Test binary, built with `go test -c` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,118 @@ | |||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is actually the code of the app :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
This PR adds contains the first POC of a Kafka Proxy that validates messages. As a poc, there has no real validation logic behind but the functionality is ready to make it happen: Right now it only prints a log line whenever a message is literally the string
invalid message
.The PR also includes a
docker-compose.yml
and aDockerfile
so we can run a one node Kafka cluster and do some testing. Readme update is pending.If you wanna play in the meantime, you can just run
docker compose up
and produce/consume messages by:Consume:
docker compose exec broker /bin/kafka-console-consumer --topic demo --from-beginning --bootstrap-server proxy:28002
Produce:
docker compose exec broker /bin/kafka-console-producer --topic demo --bootstrap-server proxy:28002
and start writing messages (stdin).As notes for developers, I managed to completely turn off my old POC (yeah, never pushed but I can share it with you as I have it locally) where I had to manage almost all the protocol handling manually (yeah, dealing with bits and bytes) and which was only supporting a particular Kafka request protocol version.
Now I'm using https://github.com/grepplabs/kafka-proxy which it has almost everything we need. In fact I had to fork it and tune it up a bit (Adding support for request handlers per Key. See the fork here. I plan to create a PR to the main project once I have more time to improve those changes I did.
I'm also using parts of the code of https://github.com/Shopify/sarama project for decoding and validating the
ProduceRequest
. I could not use the project directly because some of the interfaces I needed are private. I opened an issue few days ago regarding this: IBM/sarama#1967.One of the biggest achievements on using https://github.com/grepplabs/kafka-proxy is that it supports most of the AUTH mechanisms and also all the Kafka protocol request versions (YEEEEI!).
Next steps
How to review this PR
Even though this is a POC, most of this code could be used as the foundation of the first versions of the gateway.
That means you should review it as any other PR. Some things that were not included on this PR with the idea of doing it in another one are:
main.go
Some things that were explicitly excluded from this PR were:
/kafka
)Related issue(s)
asyncapi/shape-up-process#70