grantr/rubberband — pull request #40 by mauricio (2012-09-08 20:02:39+00:00)
Title: Fixing issue with ElasticSearch::RetryingClient trying forever and not respecting the @retries variable

We had a funky issue with our app and ended up finding out that it was being caused by Rubberband trying out forever instead of giving up.

This pull requests makes the `ElasticSearch::RetryingClient` to honor the `@retries` both for connecting on nodes as to sending requests to them, it includes specs related to the new functionality and also general specs for other pieces of `ElasticSearch::RetryingClient`.

It also contains another fix at the `ElasticSearch::AbstractClient` class by adding the following line:

```ruby
raise URI::InvalidURIError, server if uri.path.nil?
```
Is is needed because for some cases this happens:

```ruby
1.9.3-p194 :002 > require 'uri'
=> true
1.9.3-p194 :003 > uri = URI.parse "locahost:9200"
=> #
1.9.3-p194 :004 > uri.path
=> nil
```
So the `uri.path.split("/")` call would fail with a `method not found` error as `split` would be called on nil.

On a side note, I believe the whole client hierarchy would benefit from using the decorator pattern instead of the current solution based on including modules. It's really hard to write tests for it given the order of inclusion and method definition affects what method gets called and when.

If there is interest in changing this I could come up with another pull request for it.

Thanks :)