resty icon indicating copy to clipboard operation
resty copied to clipboard

Service Discovery option for clients

Open smadarasmi opened this issue 4 years ago • 2 comments

Current Behavior

Resty seems to support two ways of looking up address

  1. Specifying host information as part of url parameter which will be taken as-is if SRVRecord is not provided
  2. Use net.LookupSRV if SRVRecord is provided

Proposal

Allow for other types of service discovery.

Some projects use Consul or K8s APIs to discover the available addresses of service and does client-side round robin. It's true that one could use Consul DNS or K8s Service to avoid client-side round robin, but I'm not sure if we need to restrict this usage.

Other use cases may want to specify a list of hosts to do some weighted round robin on the client side as well.

Could we provide some Option that supports other types of addresses lookup other than net.LookupSRV? Currently, if address is specified directly to url parameter, this means that all retries will also go to the same address.

If we think that this is something useful to support, perhaps I can draw out a short spec for how we can add this functionality/option. Then I can contribute accordingly if we are in agreement.

smadarasmi avatar May 16 '21 10:05 smadarasmi

@smadarasmi I think, this is where Resty Request Middleware shines, resty could write a middleware process with their discovery service and set the request-host URL.

jeevatkm avatar Sep 13 '21 05:09 jeevatkm

I will add an interface to extend the Resty user's discovery process on v3.0.0.

jeevatkm avatar Oct 01 '23 03:10 jeevatkm