Class: Underpass::Client
- Inherits:
-
Object
- Object
- Underpass::Client
- Defined in:
- lib/underpass/client.rb
Overview
Runs the Overpass API query with retry logic for transient errors.
Handles caching of responses and automatic retries with exponential backoff for rate limiting (429) and timeout (504) responses.
Class Method Summary collapse
-
.perform(request, max_retries: nil) ⇒ Net::HTTPResponse
Performs the API request with automatic retries for rate limiting and timeouts.
Class Method Details
.perform(request, max_retries: nil) ⇒ Net::HTTPResponse
Performs the API request with automatic retries for rate limiting and timeouts.
Results are cached when a Underpass::Cache instance is configured via Underpass.cache.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/underpass/client.rb', line 23 def self.perform(request, max_retries: nil) max_retries = Underpass.configuration.max_retries if max_retries.nil? cache_key = Digest::SHA256.hexdigest(request.to_query) cached = Underpass.cache&.fetch(cache_key) return cached if cached response = perform_with_retries(request, max_retries) Underpass.cache&.store(cache_key, response) response end |