-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the use of DNS discovery for eureka connections #5
Conversation
* Doesn't handle failures gracefully * Requires that you're in AWS * Doesn't respect TTL's
Looks good to 🚢 |
if e.DNSDiscovery && len(e.discoveryTtl) == 0 { | ||
servers, ttl, err := discoverDNS(e.DiscoveryZone, e.ServicePort) | ||
if err != nil { | ||
return e.ServiceUrls[rand.Int()%len(e.ServiceUrls)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth pulling out the index part of this into a variable to just make it a little clearer what's going on.
if err != nil { | ||
return e.ServiceUrls[rand.Int()%len(e.ServiceUrls)] | ||
} | ||
e.discoveryTtl <- struct{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a bit to figure out what was going on here, but the process seems good. You could probably extract the channel ops to clear it up if you wanted to (e.needsRefresh()
, e.refreshDiscovery()
, etc). I don't have suggestions for improving the logic, though.
Allow the use of DNS discovery for eureka connections
log.Error("no answer for name=%s err=%s", fqdn, err.Error()) | ||
return nil, defaultTTL, err | ||
} | ||
if response.Answer[0].Header().Rrtype != dns.TypeTXT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could pull out response.Answer[0]
into a variable since you're using it in three places if you wanted.
LGTM |
No description provided.