Module: DruidConfig::Util
- Included in:
- Cluster, Entities::DataSource, Entities::Node, Entities::Task
- Defined in:
- lib/druid_config/util.rb
Overview
Commmon functions for the gem
Instance Method Summary collapse
-
#pop_uri ⇒ Object
Pop next base_uri.
-
#query_overlord ⇒ Object
Update the URI of HTTParty to perform queries to Overlord.
-
#secure_query ⇒ Object
This method is used to protect the Gem to API errors.
-
#stash_uri ⇒ Object
Stash current base_uri.
Instance Method Details
#pop_uri ⇒ Object
Pop next base_uri
64 65 66 67 |
# File 'lib/druid_config/util.rb', line 64 def pop_uri return if @uri_stack.nil? || @uri_stack.empty? self.class.base_uri(@uri_stack.pop) end |
#query_overlord ⇒ Object
Update the URI of HTTParty to perform queries to Overlord. After perform the query, the URI is reverted to coordinator.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/druid_config/util.rb', line 39 def query_overlord return unless block_given? stash_uri self.class.base_uri( "#{DruidConfig.client.overlord}"\ "druid/indexer/#{DruidConfig::Version::API_VERSION}") begin yield ensure # Ensure we revert the URI pop_uri end end |
#secure_query ⇒ Object
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 |
#stash_uri ⇒ Object
Stash current base_uri
56 57 58 59 |
# File 'lib/druid_config/util.rb', line 56 def stash_uri @uri_stack ||= [] @uri_stack.push self.class.base_uri end |