reactive-consul
reactive-consul copied to clipboard
selectConnection gets called before addConnectionProvider in LoadBalancerActor
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 => ... }
```
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?
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.
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.
Cool, i have not yet had time to test will do this hopefully within couple of weeks for you.
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.
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