Skip to content
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

Merged
merged 3 commits into from
Oct 18, 2021

Conversation

smoya
Copy link
Collaborator

@smoya smoya commented Oct 13, 2021

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 getting 0.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.

docs/config/kafka.md Outdated Show resolved Hide resolved
for _, v := range c.ExtraConfig {
f := strings.Split(v, "=")
_ = server.Server.Flags().Set(f[0], f[1])
}

for _, v := range c.BrokersMapping {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rearranging a bit so it makes more sense

Copy link
Collaborator

@magicmatatjahu magicmatatjahu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only on suggestion :)

docs/config/kafka.md Outdated Show resolved Hide resolved
Co-authored-by: Maciej Urbańczyk <[email protected]>
@smoya smoya merged commit 67d90c3 into asyncapi-archived-repos:master Oct 18, 2021
@smoya smoya deleted the feat/addressAdvertisement branch October 18, 2021 08:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants