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

Create Http Client without binding it to an endpoint #601

Open
moderakh opened this issue Feb 12, 2018 · 3 comments
Open

Create Http Client without binding it to an endpoint #601

moderakh opened this issue Feb 12, 2018 · 3 comments

Comments

@moderakh
Copy link

Hi,

We are on RxNetty 0.4.x. Seems passing endpoint to RxNetty.createHttpClient(.) is required.
https://github.com/ReactiveX/RxNetty/blob/0.4.x/rxnetty/src/main/java/io/reactivex/netty/RxNetty.java#L169-L170

I wonder how we should instantiate an http client using rxnetty without binding it to a specific endpoint at the instantiation time? (The use case is for fail over scenarios from one endpoint to other endpoint known at runtime)

Other http clients (e.g., apache http client) allow instantiating a client without binding it to a specific endpoint at the instantiation time, but not sure how to do it using rxnetty

Thanks

@jamesgorman2
Copy link
Collaborator

No good answer on why. My only advise would be to create a factory method/object to hide this away.

I think this should be another candidate for review in 1.0.x

@moderakh
Copy link
Author

@jamesgorman2 wouldn't https://github.com/ReactiveX/RxNetty/blob/0.4.x/rxnetty/src/main/java/io/reactivex/netty/protocol/http/client/CompositeHttpClient.java work for this purpose?

I found this in the documentation:

/**
 * An implementation of {@link HttpClient} that can execute requests over multiple hosts.
 * Internally this implementation uses one {@link HttpClientImpl} per unique
 * {@link io.reactivex.netty.client.RxClient.ServerInfo}.
 * The only way to create this client is via the {@link CompositeHttpClientBuilder}
 *
 * @author Nitesh Kant
 */
public class CompositeHttpClient<I, O> extends HttpClientImpl<I, O> {

@jamesgorman2
Copy link
Collaborator

Just did a quick scan of the code and it looks like that will do what you want. This wasn't ported to 0.5.x so I missed it.

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