Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kafka): additional advertised listeners/broker addresses for kafka #2920

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/modules/kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ The Kafka container will be started using a custom shell script:
[Init script](../../modules/kafka/kafka.go) inside_block:starterScript
<!--/codeinclude-->

That will set the advertised listeners with these values:

<!--codeinclude-->
[Advertised Listeners](../../modules/kafka/kafka.go) inside_block:advertisedListeners
<!--/codeinclude-->

KafkaContainer provides methods to read the broker addresses for different
connectivity environments.

#### Environment variables

The environment variables that are already set by default are:
Expand All @@ -82,3 +91,33 @@ The `Brokers(ctx)` method returns the Kafka brokers as a string slice, containin
<!--codeinclude-->
[Get Kafka brokers](../../modules/kafka/kafka_test.go) inside_block:getBrokers
<!--/codeinclude-->

#### BrokersByHostDockerInternal

The `BrokersByHostDockerInternal(ctx)` method returns the Kafka brokers as a
string slice, containing the hostname `host.docker.internal:<random_port>`.

This method is useful when you need to run additional containers that need to
connect to Kafka.

<!--codeinclude-->
[Get Kafka brokers by host.docker.internal](../../modules/kafka/examples_test.go) inside_block:getBrokersByHostDockerInternal
<!--/codeinclude-->

#### BrokersByContainerName

The `BrokersByContainerName(ctx)` method returns the Kafka brokers as a string
slice, addressed by the container's name(`Ex: charming_dijkstra:19093`). This
method is useful when you need to run additional containers that need to connect
to Kafka.

To use this broker address you should run all the containers inside a docker
network.

<!--codeinclude-->
[First start Kafka inside a docker network](../../modules/kafka/examples_test.go) inside_block:getBrokersByContainerName_Kafka
<!--/codeinclude-->

<!--codeinclude-->
[Then start a second container in the same network](../../modules/kafka/examples_test.go) inside_block:getBrokersByContainerName_Kcat
<!--/codeinclude-->
Loading
Loading