Closed perlun closed 11 years ago
Using a strategy pattern here might make more sense. Less conditionals.
Care to elaborate? Or even better, PR my PR. :)
Can't you obtain the current DNS servers via ipconfig?
@perlun A class with the specific method implemented for each different type.
Yeah, but I don't know if its so much cleaner. :) Works on MRI also though, which is an obvious plus.
Sent from my iPhone
On 28 maj 2013, at 23:41, "Tony Arcieri" notifications@github.com<mailto:notifications@github.com> wrote:
Can't you obtain the current DNS servers via ipconfig?
— Reply to this email directly or view it on GitHubhttps://github.com/celluloid/celluloid-io/pull/65#issuecomment-18578297.
It would be one codepath regardless, which to me seems like a big win.
The trivial version could just hit ipconfig for each resolution request. Bonus points for a short-lived cache of domain names.
@tarcieri careful about caching. dislike caching in app code. nothing worse than buggy DNS cache code.
I think the cache is fine if it's extremely short lived (5 seconds... or even 1 second)
I fixed a basic version of the 'ipconfig /all' approach, which should work on both MRI and JRuby. Ugly in my eyes, and even worse - I'm not sure it will work correctly on a non-English version of Windows...
Nonetheless, here it is. I think it would be better to use the Java API when on JRuby and use a Win32 API in MRI...
@halorgium: I'll gladly switch over to a strategy-based approach. Any suggestions to how it can be done? A separate class used by DNSResolver? (its instantiation still has to be conditionalized though, but it might still be slightly cleaner.)
@perlun I can factor this into multiple providers if you're having trouble. Forget the ipconfig cache, let's just use ipconfig as a fallback implementation, and implement some other more elegant providers we can use if available
@tarcieri: OK. I'll work a bit more on this in the direction as you suggested - thanks for the feedback! Will let you know when it is ready for peer review/refactoring.
@perlun check out @Dparker1990's work, he's trying to move to Resolv::Hosts: https://github.com/celluloid/celluloid-io/pull/73
@tarcieri Good point. I looked at it and it doesn't solve the same problem, but it's definitely good and I believe we should try to merge both of these PRs for 0.15.
The specs work with my branch now on JRuby Windows and JRuby Mac OSX. Didn't get rspec working on MRI/OSX for some reason but I guess Travis will let us know in a few minutes... :)
@perlun cool, I'd like to land @Dparker1990's patch first then revisit yours
@tarcieri Fine by me. Please if you remember, poke me when it has been merged so I can pull in his changes into my tree. Btw, there was a regression with MRI that Travis told me about so I fixed that also.
This issue is out-of-date and the DNS resolver code has changed considerably
OK, I'll see if it get the time/energy to try to rebase the fixes on top of the latest master. Was awaiting the @DParker1990 PR to be merged but I presume this has happened now?
Yes. Try to rebase if you can, but a lot has changed
Yeah, it will probably not be a true rebase in the git sense but more a "logical rebase" off of the new head.
... on JRuby/Windows.