Open mhamann opened 7 years ago
I added code to the TCP adapter's Dial
method that looks like this:
import "github.com/benschw/srv-lb/lb"
func (_ *tcpTransport) Dial(addr string, options map[string]string) (net.Conn, error) {
if v := strings.Split(addr, ":"); len(v) < 2 {
cfg, err := lb.DefaultConfig()
if err != nil {
return nil, err
}
l := lb.New(cfg, addr)
resolvAddr, err := l.Next()
if err == nil {
addr = resolvAddr.String()
}
}
raddr, err := net.ResolveTCPAddr("tcp", addr)
if err != nil {
return nil, err
}
conn, err := net.DialTCP("tcp", nil, raddr)
if err != nil {
return nil, err
}
return conn, nil
}
Ideally, it seems like creating a common wrapper for Dial
would be a nice place to put this code. Another option would be to put the DNS resolution code in its own function and just reference it from each transport.
Thoughts?
Yea seems like this doesn't work right now. Maybe that quote was aspirational at one point. In any case, I'd accept a patch that had the string parsing/resolution in their own functions and have the udp and tcp transports call out to them like you described. Let me know if you have time to put that together; with tests please. Otherwise I'll get to it at some point in the next few weeks.
I have it done for TLS. I just need to clean it up a bit and apply to the other transports. Will try to get a PR in next week.
According to the docs Logspout should look for a route address's DNS SRV records to figure out which ports to hit:
This is not working in practice. Attempting to add a route using the example in the
routesapi
doc (which uses a format likeloggregator.service.consul
) simply results in an error:Bad route: missing port in address
Here's the actual API call I'm making:
And here's the response from
dig
(inside the container) showing valid DNS records being returned (including SRV):