Module: DruidConfig::Util

Included in:
Cluster
Defined in:
lib/druid_config/util.rb

Overview

Commmon functions for the gem

Instance Method Summary collapse

Instance Method Details

#secure_queryObject

This method is used to protect the Gem to API errors. If a query fails, the client will be reset and try the query to new coordinator. If it fails too, a DruidApiError will be launched.

If the error comes from another point of the code, the Exception is launched normally



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/druid_config/util.rb', line 17

def secure_query
  return unless block_given?
  @retries = 0
  begin
    yield
  rescue HTTParty::RedirectionTooDeep => e
    raise(DruidApiError, e) if @retries > 0
    @retries += 1
    reset!
    retry
  rescue Errno::ECONNREFUSED => e
    raise(DruidApiError, e) if @retries > 0
    @retries += 1
    reset!
    retry
  end
end