go-zookeeper / zk

Native ZooKeeper client for Go
BSD 3-Clause "New" or "Revised" License
515 stars 130 forks source link

Added constructor for DNSHostProvider #118

Closed noname0443 closed 8 months ago

noname0443 commented 10 months ago

This pull request aims to add an option to change logic of dns host resolving.

In my scenario, when I scale the K8s cluster down then extra replicas will be deleted, and its dns records will be deleted too. With the given state of affairs, I need to update host list on every pod to evade errors:

  1. https://github.com/go-zookeeper/zk/blob/c5e730e9ba62dbf3912923fdad523ed89192fb3b/dnshostprovider.go#L41C5-L41C5
  2. https://github.com/go-zookeeper/zk/blob/c5e730e9ba62dbf3912923fdad523ed89192fb3b/conn.go#L216

but I think it's preferable in the situation to ignore a part of those hosts to improve reliability. In other words, I want to pass my own host resolve logic in DNSHostProvider. In my opinion, a constructor is the best way to achieve this.