Per discussion on the finaglers mailing list: https://groups.google.com/d/msg/finaglers/HqfNWJF3qZk/mWD-By0MtOgJ
DnsCluster continuously resolves a host name into a set of SocketAddress instances, loosely based on ZK cluster implementation .
LingeringCluster is a generic Cluster filter that propagates Rem events after a predefined delay, this helps dealing with firewall that does its own DNS resolution.
implemented LingeringCluster and DnsCluster
switched to using SpoolSource
Turned DnsCluster into a trait
I like the idea here, but Clusters are deprecated. It doesn't make sense to add a new one right now. Can you get these to work with the Name api?
It should be pretty simple to adopt to the new APIs.
(This is really cool btw.)
I've looked at ZkResolver to see how to implement a similar DnsResolver, but it uses a Group internally and there's a comment about taking that out as well (I understand Groups are deprecated too). I wonder if my best strategy is to wait until the dust settles and then take another look? Or am I barking up the wrong tree?
The deprecation storm has settled and the Name/Var[Addr] API is the outcome. I think it's safe to assume that it's stable enough to build upon. ZkResolver is still written in terms of Group because no one's had time to migrate StabilizingGroup to the Var[Addr] world.
A DnsResolver would provide a function def bind(arg: String): Var[Addr]. See twitter-server's FlagResolver class for a simple example.
def bind(arg: String): Var[Addr]
Thanks for your response, but I am still a bit confused where my DNS stuff would fit in this brave new world... On one hand, it could be used as a poor man's ZK, with multiple machines resolving the same hostname, so that's why I looked at the ZkResolver, but then we can also have a Name implementation, something like this: https://gist.github.com/agleyzer/7363353. What would you guys prefer?
I think we just want this to be part of the inet! resolver.
Merge remote-tracking branch 'local/master'
Merge remote-tracking branch 'upstream/master'
@agleyzer Not sure if you're still interested in this problem, but I just stumbled on this ticket again. I think @mariusaeriksen is right that this shouldn't be special behavior, this should just be the way that the InetResolver works all the time. Do you still have the bandwidth to make this happen?
@mosesn We keep getting bit by inet! resolved names failing to track DNS names that change over time (e.g. AWS ELBs), so I'd be interested in working this into the inet! resolver if no one is tackling it yet.
What's the best approach?
Stick with Name.Bound(Var[Addr]) (Resolver.eval + InetResolver.bind) and periodically push DNS changes to the Var. This would require periodically re-resolving the hostname on a Timer, which seems like it might be overly complicated.
Add some kind of "bind-on-demand" state in Addr so that DNS resolution happens on each request. Is this even possible?—looking at DefaultClient.newStack0 my guess is that it needs the push behavior in (1)...
@mosesn sorry I just noticed your question. I might have some bandwidth next week.
@jdanbrown I ended up writing a subclass for Name with periodic changes: https://gist.github.com/agleyzer/7363353, it's been in use for a while, no complains so far.
@agleyzer that solution looks great. Would you mind if @jdanbrown refashioned it to be the default for "inet!"?
+1, this looks great.
We should consider doing a few things:
In the long term, we might consider implementing our own DNS resolver (I think that there was a Netty summer-of-code project for this -- @trustin?) so that we can respect the upstream TTLs, etc. But, I know that anything involving "your own DNS resolver" is tantamount to famous last words.
@mosesn @jdanbrown you are welcome to use that code, I am glad to be of any help
Awesome. @jdanbrown let me know if you need any help.
Yeah, Netty has an asynchronous DNS resolution facility which came from last year's GSoC. It has not been merged yet because it needs some clean-up. Will let you know once it's ready to go.
@agleyzer @jdanbrown looks like this fell through the cracks, do either of you have the bandwidth to take this on?
@mosesn , we are using the DNS Resolver written by @agleyzer in our product, and it works well. Can I know what is the progress to support automatically DNS resolving in finagle? I can help on issue if @agleyzer doesn't have time.
Sure, if you want to take it on, we'd be glad to take your PR. None of us at twitter has the bandwidth to do it, so it will have to be community driven.
@mosesn @agleyzer @jixu Yeah, sorry, I dropped the ball on this. I still intend to do it eventually, but @jixu feel free to jump on it sooner if you want. Either way, I'll follow up here before I spend much time on it to make sure I'm not racing with someone else.
@mosesn I have created a pull request for this issue:
Please help to review when you have time.
#282 implemented this, so I'm going to close this PR. Thanks to @jixu and @agleyzer for this super cool feature!