kafka-go icon indicating copy to clipboard operation
kafka-go copied to clipboard

Allow the resolver to override the port setting

Open themulle opened this issue 3 years ago • 5 comments

The custom resolver couldn't override the default port even if id had been explicitly provided. The reason for that is unclear as it contradicts the open closed principle. Why: Common address resolvers should alway only return the host. If a port is being provided this has been intended.

Purpose of this Patch: Access a kafka cluster behind a firewall via portforwarding on a jump host. jumphost: 9095 -> kafkahost1:9092, jumphost: 9096 -> kafkahost2:9092, ...

themulle avatar Nov 30 '21 14:11 themulle

Port overrides seem to have been prevented due to the default ports being provided. The test had to be adapted but seemed a bit akward to me. Prior: example.com:9092 -> 127.0.0.1:80 resulted in 127.0.0.1:9092 (why?) Now: example.com:9092 -> 127.0.0.1:80 results in 127.0.0.1:80

themulle avatar Nov 30 '21 17:11 themulle

Hello @themulle, thanks for submitting this pull request.

I left a question about the implementation, let me know what you think!

achille-roussel avatar Jan 28 '22 18:01 achille-roussel

finally a good solution after digging into net/ip.go to understand the behaviour of net.SplitHostPort

themulle avatar Feb 21 '22 20:02 themulle

hi, this commit hasn't been merged into the main branch yet(I have the same problem)

chris-wangkk avatar Aug 04 '22 02:08 chris-wangkk

Hello @chris-wangkk

The original author appears to have abandoned the pull request. There were a few comments left that haven't been addressed.

Would you be available to take over and complete this work?

achille-roussel avatar Aug 26 '22 16:08 achille-roussel