{"action":"created","issue":{"url":"https://api.github.com/repos/jurmous/etcd4j/issues/41","labels_url":"https://api.github.com/repos/jurmous/etcd4j/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/jurmous/etcd4j/issues/41/comments","events_url":"https://api.github.com/repos/jurmous/etcd4j/issues/41/events","html_url":"https://github.com/jurmous/etcd4j/issues/41","id":73908400,"number":41,"title":"Support for SRV records","user":{"login":"OskarKjellin","id":1304771,"avatar_url":"https://avatars.githubusercontent.com/u/1304771?v=3","gravatar_id":"","url":"https://api.github.com/users/OskarKjellin","html_url":"https://github.com/OskarKjellin","followers_url":"https://api.github.com/users/OskarKjellin/followers","following_url":"https://api.github.com/users/OskarKjellin/following{/other_user}","gists_url":"https://api.github.com/users/OskarKjellin/gists{/gist_id}","starred_url":"https://api.github.com/users/OskarKjellin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OskarKjellin/subscriptions","organizations_url":"https://api.github.com/users/OskarKjellin/orgs","repos_url":"https://api.github.com/users/OskarKjellin/repos","events_url":"https://api.github.com/users/OskarKjellin/events{/privacy}","received_events_url":"https://api.github.com/users/OskarKjellin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-07T09:07:41Z","updated_at":"2015-05-11T08:50:42Z","closed_at":null,"body":"Etcd allows to bootstrap over SRV records and tools such as confd supports reading them. Would be nice if etcd4j could read them. This is the code that I am using the bootstrap etcd4j using SRV records (I can make a PR if you want to). \r\nhttps://github.com/coreos/etcd/blob/master/Documentation/clustering.md#dns-discovery\r\nDoes this sound like a good idea?\r\n\r\n    private URI[] getUris(String service) throws NamingException {\r\n        List<URI> uris = new ArrayList<>();\r\n        String srvService = \"_etcd._tcp.\" + service;\r\n        Hashtable<String, String> env = new Hashtable<>();\r\n        env.put(\"java.naming.factory.initial\", \"com.sun.jndi.dns.DnsContextFactory\");\r\n        env.put(\"java.naming.provider.url\", \"dns:\");\r\n        DirContext ctx = new InitialDirContext(env);\r\n        Attributes attributes = ctx.getAttributes(srvService, new String[]{\"SRV\"});\r\n        NamingEnumeration<? extends Attribute> records = attributes.getAll();\r\n        while (records.hasMore()) {\r\n            Attribute next = records.next();\r\n            NamingEnumeration<String> values = (NamingEnumeration<String>) next.getAll();\r\n            while (values.hasMore()) {\r\n                String dns = values.next();\r\n                String[] split = dns.split(\" \");\r\n                String port = split[2];\r\n                String host = split[3];\r\n                URI uri = URI.create(\"http://\" + host + \":\" + port);\r\n                uris.add(uri);\r\n            }\r\n        }\r\n        return uris.toArray(new URI[0]);\r\n    }\r\n"},"comment":{"url":"https://api.github.com/repos/jurmous/etcd4j/issues/comments/100819653","html_url":"https://github.com/jurmous/etcd4j/issues/41#issuecomment-100819653","issue_url":"https://api.github.com/repos/jurmous/etcd4j/issues/41","id":100819653,"user":{"login":"jurmous","id":6823511,"avatar_url":"https://avatars.githubusercontent.com/u/6823511?v=3","gravatar_id":"","url":"https://api.github.com/users/jurmous","html_url":"https://github.com/jurmous","followers_url":"https://api.github.com/users/jurmous/followers","following_url":"https://api.github.com/users/jurmous/following{/other_user}","gists_url":"https://api.github.com/users/jurmous/gists{/gist_id}","starred_url":"https://api.github.com/users/jurmous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jurmous/subscriptions","organizations_url":"https://api.github.com/users/jurmous/orgs","repos_url":"https://api.github.com/users/jurmous/repos","events_url":"https://api.github.com/users/jurmous/events{/privacy}","received_events_url":"https://api.github.com/users/jurmous/received_events","type":"User","site_admin":false},"created_at":"2015-05-11T08:50:42Z","updated_at":"2015-05-11T08:50:42Z","body":"Ah yes, I somehow forget to check the link so I missed it is also in etcd itself. That is a pretty good argument and I will now integrate the support into etcd4j. \r\n\r\nI will probably add a utility class to convert the DNS SRV record information to URI[] so it can be passed on to EtcdClient.\r\n\r\nThanks for the code and the suggestion!"}}