retrofit icon indicating copy to clipboard operation
retrofit copied to clipboard

Client-Side host load-balance

Open PiemonJ opened this issue 3 years ago • 1 comments

  • [ ] Feature Request. i have found my company use client-side ip load-balance,the http domain is a special service identifier,for example:global-user-credit,then have a common method to get ip list from register center,then perform client-side load balancing。but this special service identifier cannot be recognized by retrofit‘s HttpUrl class.so i have requirement,the OkHttpClient.Builder to provider a new method ,for example:baseUrlFactory,allows us to dynamically set base IP.

PiemonJ avatar Aug 05 '22 12:08 PiemonJ

Our general policy for this has been to use an OkHttp interceptor to rewrite the Request object to target the desired host. You can use a global host at the Retrofit layer or even just use a dummy domain like example.com to ensure the interceptor is required to rewrite the URL.

In the future, we may consider a factory for base URLs which is invoked each time a request is created.

JakeWharton avatar Nov 30 '22 04:11 JakeWharton