Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

thread safety? #69

Closed
ckstettler opened this issue Oct 14, 2015 · 2 comments
Closed

thread safety? #69

ckstettler opened this issue Oct 14, 2015 · 2 comments

Comments

@ckstettler
Copy link

Not sure if this is the correct forum... if not I apologize upfront.

We are looking to use this api and are wanting to understand a couple of points:

  • is it thread safe?
  • the examples show creating an instance with every lookup. We are looking to use consul as an endpoint locator and could have a high volume of requests. Should we pool client connections? use one? or create a new one everytime. Our assumption is the consul agent is local to our app as well.
@gjesse
Copy link
Contributor

gjesse commented Oct 14, 2015

I can't totally vouch for thread safety of the entire code base but in general you should be OK. there is very little mutable internal state, and the request/response model objects are immutable.

The underlying http connections are handled by your favorite jax-rs implementation, which should be fine. Depending on your implementation you can configure pooling for it. (ex for jersey: http://www.theotherian.com/2013/08/jersey-client-2.0-httpclient-timeouts-max-connections.html)

As far as instances, you can create a single ConsulClient instance and reuse it.

@rickfast
Copy link
Owner

I can vouch for the thread safety of the client. You definitely only need one instance per JVM.

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

No branches or pull requests

3 participants