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

selectConnection gets called before addConnectionProvider in LoadBalancerActor #18

Open
sjoerdmulder opened this issue Aug 24, 2017 · 6 comments

Comments

@sjoerdmulder
Copy link
Contributor

Having the example new ServiceBroker and immediately call withService then the selectConnection is called on the LoadBalancerActor before the connection providers are added causing an ServiceUnavailableException exception

Example:

val serviceBroker = ServiceBroker(new URL("http://consul.service.consul:8500"), connectionStrategies)
serviceBroker.withService[String, Unit]("my-service") { value => ... }
```
@dlouwers
Copy link
Owner

dlouwers commented Aug 24, 2017

Hi @sjoerdmulder,

What do you feel would be reasonable behavior?
I could either introduce the concept of 'readiness' to the ServiceBroker constructor, having it return a Future[ServiceBroker] or I could build some mechanism into withService that would await the first query of Consul along with the construction of connections. I feel that the latter option would probably be the most user-friendly, agreed?

@sjoerdmulder
Copy link
Contributor Author

Yeah, last option is better since it's already returns a Future. Great project BTW! If you need any help or want a PR let me know.

@dlouwers
Copy link
Owner

Hi @sjoerdmulder. I am now stashing GetConnection messages until the first consul query has been done. This means that you might still not get a connection if Consul isn't aware of it ofc. Please try the 0.4.0 snapshot.

@sjoerdmulder
Copy link
Contributor Author

Cool, i have not yet had time to test will do this hopefully within couple of weeks for you.

@dlouwers
Copy link
Owner

Hi @sjoerdmulder. I have given it some thought and have come to the conclusion that this feature has added far more complexity than it solves. In a next release, I will remove this feature in favor of advising people to use a retry mechanism from the outside.

@sjoerdmulder
Copy link
Contributor Author

Ok, no problem. The problem is likely not happening in real code since the creation of ServiceBroker happens on startup and after some time when the service is ready / started it will start using the .withService

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