This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
feat: set a reachable address for proxy that brokers will use for advertisement #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Some Kafka protocol internals required to understand this change:
In order to connect to Kafka brokers, clients need to ask first for a full list of partition assignments to, at least, one Kafka broker (Bootstrap(s) broker). This is the very first request a client does.
The response includes a collection of broker host:port mappings, the partitions assigned to each broker, and some other info. If you are interested and want to read more about Kafka protocol, you can refer to kafka.apache.org/protocol and look for "Metadata Response".
Description
Since the Kafka proxy of the event-gateway intercepts all requests, it can modify the response of such Metadata Request so it overrides the mappings on host with the proxy ones, so it ensures clients always will use the proxy addresses instead of the ones on final brokers. This is something the current code does.
However, all brokers were bind to local address
0.0.0.0:<port>
, meaning that Kafka clients were getting0.0.0.0
as host for all Kafka brokers. Obviously, this won't work outside local environments.This PR adds the possibility to set a reachable Proxy address so it is used when specified on that Metadata response, letting Kafka clients to connect any broker always through the Proxy on the event-gateway.
Note that the way it's configured is through env var. However, once we move forward with #59 it won't be needed since the URL will be the fetched from server object URL :)
However, we could keep the env var so it can be overridden if we want.