etcd-ruby icon indicating copy to clipboard operation
etcd-ruby copied to clipboard

Support SRV discovery

Open kylev opened this issue 9 years ago • 0 comments

The etcd clustering guide specifies a discovery mechanism via SRV records. This would allow a client to discover a cluster via domain alone, allowing for centralized listing and distributed discovery.

Proposed design would accept a :domain option to the client constructor. in its presence, the :host and :port would be ignored and DNS would be used to determine those options.

I currently use a factory method like this to generate a client:

require 'resolv'
require 'etcd'

def by_domain(domain)
  srv_query = "_etcd-client._tcp.#{domain}"
  srv_records = Resolv::DNS.new.getresources(srv_query, Resolv::DNS::Resource::IN::SRV)
  chosen = srv_records.sample
  Etcd.client(host: chosen.target, port: chosen.port)
end

kylev avatar May 17 '16 01:05 kylev