Kafka client GenServer restarting

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?..

You can change permanent to transient. This will restart client only if it terminates with abnormal reason. Using this, you can exit with normal reason when the topic name is wrong

Unable. permanent is hardcoded in Brod library. Only thing you can change is delay between restarts.

My solution was to again use Brod to ping the brokers via get_metadata() and create client and producer only if response was {:ok, _metadata}. Otherwise I don’t create brokers and return :error.