Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestAdapter should accept multiple servers #385

Closed
mhickman opened this issue Jan 23, 2014 · 3 comments
Closed

RestAdapter should accept multiple servers #385

mhickman opened this issue Jan 23, 2014 · 3 comments

Comments

@mhickman
Copy link

I have a need where I want to round robin between different servers that expose the same REST api. My initial thoughts for doing this were either:

  • Pool N instances of the rest client
  • Extend the Server class so getUrl() works in round robin fahion
  • Stick something like nginx in front of the client.

I can do either of these with retrofit as is, but would guys consider a PR specify a set of servers in RestAdapter.Builder?

@JakeWharton
Copy link
Member

The reason RestAdapter calls getUrl each request rather than caching the
value is so that you can do things like this.
On Jan 22, 2014 10:05 PM, "Matt Hickman" notifications@github.com wrote:

I have a need where I want to round robin between different servers that
expose the same REST api. My initial thoughts for doing this were either:

  • Pool N instances of the rest client
  • Extend the Server class so getUrl() works in round robin fahion
  • Stick something like nginx in front of the client.

I can do either of these with retrofit as is, but would guys consider a PR
specify a set of servers in RestAdapter.Builder?


Reply to this email directly or view it on GitHubhttps://github.com//issues/385
.

@mhickman
Copy link
Author

Cool I'll just use that.

@JakeWharton
Copy link
Member

Just wanted to follow up on a computer where I can type more.

Server was designed with cases like this in mind. You can update the endpoint that requests go to based on things like geolocation around the world or in a round robin pattern like you said. We expose ChangeableServer which has explicit APIs for controlling the URL, but you'd definitely want a custom subclass that did a rotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants