retrofit
retrofit copied to clipboard
Client-Side host load-balance
- [ ] 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.
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.