I have a usecase where kafka endpoind information is entered by user. The endpoint is bound into Brod Client I’m starting and if that succeeds I start a Producer from that Client. If something fails, the GenServer is configured to do restart: :permanent
. Which is a good thing because you want your client to try to restart if connection is severed or GenServer crashes for any reason. BUT since user entries are not fool-proof, a bad input such as non-existent Kafka broker will put GenServer into permanent
restart loop.
How to best handle the situation where I want to avoid creating a client when user enters invalid Kafka configuration, but keep permanent
restart mode if the configuration is valid?
Brod is doing it! brod/brod_sup.erl at 3.7.9 · kafka4beam/brod · GitHub
Maybe the best protection is to have separate code that validates the endpoint
user entry and makes sure it’s live before attempting to start a client instance?..