@@ -61,6 +61,15 @@ The Kafka container will be started using a custom shell script:
61
61
[Init script](../../modules/kafka/kafka.go) inside_block:starterScript
62
62
<!--/codeinclude-->
63
63
64
+ That will set the advertised listeners with these values:
65
+
66
+ <!--codeinclude-->
67
+ [Advertised Listeners](../../modules/kafka/kafka.go) inside_block:advertisedListeners
68
+ <!--/codeinclude-->
69
+
70
+ KafkaContainer provides methods to read the broker addresses for different
71
+ connectivity environments.
72
+
64
73
#### Environment variables
65
74
66
75
The environment variables that are already set by default are:
@@ -82,3 +91,34 @@ The `Brokers(ctx)` method returns the Kafka brokers as a string slice, containin
82
91
<!--codeinclude-->
83
92
[Get Kafka brokers](../../modules/kafka/kafka_test.go) inside_block:getBrokers
84
93
<!--/codeinclude-->
94
+
95
+ #### BrokersByHostDockerInternal
96
+
97
+ The `BrokersByHostDockerInternal(ctx)` method returns the Kafka brokers as a
98
+ string slice, containing the hostname `host.docker.internal` and a random port
99
+ defined by Kafka' s public port (` 19092/tcp` ).
100
+
101
+ This method is useful when you need to run additional containers that need to
102
+ connect to Kafka .
103
+
104
+ <!--codeinclude-->
105
+ [Get Kafka brokers by host.docker .internal ](../../modules/kafka/examples_test.go ) inside_block:getBrokersByHostDockerInternal
106
+ <!--/codeinclude-->
107
+
108
+ #### BrokersByContainerName
109
+
110
+ The ` BrokersByContainerName(ctx)` method returns the Kafka brokers as a string
111
+ slice, addressed by the container' s name(`Ex: charming_dijkstra:19093`). This
112
+ method is useful when you need to run additional containers that need to connect
113
+ to Kafka.
114
+
115
+ To use this broker address you should run all the containers inside a docker
116
+ network.
117
+
118
+ <!--codeinclude-->
119
+ [Start Kafka inside a docker network](../../modules/kafka/examples_test.go) inside_block:getBrokersByContainerName_Kafka
120
+ <!--/codeinclude-->
121
+
122
+ <!--codeinclude-->
123
+ [Get Kafka brokers by container name](../../modules/kafka/examples_test.go) inside_block:getBrokersByContainerName_Kcat
124
+ <!--/codeinclude-->
0 commit comments