Implement resolve_canonical_bootstrap_servers_only
This PR allows specifying the equivalent of client.dns.lookup=resolve_canonical_bootstrap_servers_only, described in KIP-235. The motivation is identical to the one in the proposal: the lack of this feature effectively mandates providing individual canonical broker hostnames when using GSSAPI, rather than a single alias which resolves to the same underlying IPs. This increases the likelihood of errors, and commits application owners to checking for new and removed brokers on an ongoing basis.
The Java client implementation for this can be found here.
The config could be designed as a type DNSLookupStrategy int8 enum, with UseAllDNSIPs and ResolveCanonicalBootstrapServersOnly values, however I went for the bool as there is no precedent for mirroring the Java API, and this seemed much simpler to understand.
I was torn about adding context.Context to resolveCanonicalNames()'s signature. To be consistent with existing code, I've kept this internal. It is not fully supported anyway due to Net.Proxy.Dialer being a proxy.Dialer rather than proxy.ContextDialer.
@dnwe Please let me know if this is missing anything!
@dnwe I've rebased and added Signed-off-by. Still really keen to add this feature :)
The Test with Kafka 3.1.2 failure was due to a timeout only 8 tests from the end:
| STATUS | ELAPSED | PACKAGE | COVER | PASS | FAIL | SKIP |
|---|---|---|---|---|---|---|
| FAIL | 960.07s | github.com/Shopify/sarama | - | 423 | 8 | 1 |
| PASS | 0.03s | github.com/Shopify/sarama/examples/http_server | 22.5% | 3 | 0 | 0 |
| PASS | 0.04s | github.com/Shopify/sarama/mocks | 82.1% | 36 | 0 | 0 |
There are no changes here that would affect performance once connected to brokers, so I think that's a false negative. I've rebased, can you re-approve the workflow to give it another go?
Thanks! Please let me know if I need to do anything else - I'll hold off rebasing the source branch, as it'll only wait for the checks to be re-approved.