Add a DNS-based EndpointGroup
See original GitHub issueMany service discovery systems support returning a list of endpoints as records in a DNS response, and since DNS resolution is built into netty, it makes sense for armeria to add support out of the box. Some methods use A
records with IP addresses and others use SRV
records with CNAMEs - so armeria should ideally support at least both of these.
I dug through netty’s DNS resolver package and found a lot of useful logic, but am not sure if there is a good integration point for it.
The biggest problem is I don’t see a way to support SRV
records - the API only exposes knobs for address family, e.g. IPV4 and IPV6, which correspond to A
and AAAA
only.
I think we also need a way to always be able to know the most recent result for the DNS query for monitoring - it’s very important to be able to present the mapping from service name -> resolved endpoints, and it’s not clear this can be accomplished with the default DnsNameResolver
(maybe by showing the state of the dns cache?).
That said, there’s much logic in DnsNameResolver
, DnsNameResolverContext
, and RoundRobinDnsAddressResolverGroup
that I don’t think we want to duplicate into an endpoint group implementation.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top GitHub Comments
Just to follow up, I’ve mostly completed an implementation that manually handles the query response. While a good amount of copy-paste, by removing some of the more esoteric features that probably don’t apply in service discovery, I could simplify it quite a bit.
https://github.com/anuraaga/armeria/blob/dev_rag/core/src/main/java/com/linecorp/armeria/client/endpoint/dns/DnsEndpointGroup.java
Yeah - I found query and am able to get DNS responses - but found there’s tons and tons of logic dealing with correctly handling the response. It would be quite sad to have to duplicate it
https://github.com/netty/netty/blob/4.1/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverContext.java#L336
It’s why using resolve would be much nicer, but has the limitation of no
SRV
support. Any thoughts on a cleaner way to avoid duplicating what looks like pretty hairy (i.e. easily buggy) code?If there doesn’t seem to be a good way, or clean netty integration point, will just copy-paste 😃