Tools for working with DNS SRV records for microservices

I have a shiny app that finds a backend plumber API via a DNS A record (hitting a HTTP endpoint on a static port) that I need to move over to use SRV records. SRV records return a port and a target hostname and the target hostname needs to be also looked up and resolved to hit the proper endpoint. SRV records like this are a pretty common pattern in microservices but I'm not finding any tools that will allow me to query this DNS record type and get an ultimate hostname and port combination out of the box.

I can write something to pipe to a system level nslookup or dig interface, but as this code will be deployed in a docker container with a minimal userland, I'd love to avoid having to specify a hard dependency on a particular command line tool.

Have any services-oriented architects wrangled this sort of pattern before? Tips and pointers?

This is very interesting! I am not personally familiar, unfortunately. However, I do not find it super surprising that this functionality might be either (1) missing or (2) hard to find in the R community, since the community has precious few computer scientists / micro-service architects compared to languages like Python and Go.

I think this functionality would make a very cool addition to the R community, though, if you are obliged to start such a package! If you are already making use of python, you could use the reticulate package to call out to a python library pretty easily. Alternatively, C++ via Rcpp would be another readily available option to building such things yourself.

I personally like using Go, but a lot of work still needs to be done to get Go compilation integrated nicely into the R ecosystem. There are a few experiments out there, but in my experience, they are very rough around the edges :sweat_smile:

1 Like

Wouldn't the nslookup function in package curl be able to do that?

Hi, @meztez! I didn't know about curl::nslookup(), so thanks for that! Unfortunately, that only queries for the A records and can't be used to query and parse SRV records.

Hi there, @cole. Thanks for the feedback!

For my immediate need, I deployed a sidecar container running HAProxy. HAProxy does the service discovery and my local contain just needs to hit localhost to get to the proxy, which then routes to the service.

I'm hoping to see support for SRV records come into the nsl package, where I have an issue open. That seems like the best home for this functionality. I'd really like to avoid wrapping python. Yuck! :wink:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.