Simple example.
Load balancer example.
Load balancer example.
In this example we'll show the load balancer support. The default load balancer requires you to implement 'resources' that returns all available resources. When this is not dynamic, simply implement 'resources' as a val (as done in this example).
Upon invoking the load balancer it randomly picks one of the given resources and tries to use it. When a NotAvailable exception is caught, the next resource is attempted.
If the resource throws any other error, the error is simply rethrown and not further attempt to invoke another resource is done.
This is the resource we're going to call in the examples.
Little helper method to assert that the given code throws an exception of given type.
Some runnable examples to show how to use sentries.