mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
Return sidekiq_rate_limiting
This commit is contained in:
parent
2b2583e275
commit
6093f4cb33
4 changed files with 13 additions and 1 deletions
1
Gemfile
1
Gemfile
|
|
@ -27,6 +27,7 @@ gem 'rswag-ui'
|
||||||
gem 'shrine', '~> 3.6'
|
gem 'shrine', '~> 3.6'
|
||||||
gem 'sidekiq'
|
gem 'sidekiq'
|
||||||
gem 'sidekiq-cron'
|
gem 'sidekiq-cron'
|
||||||
|
gem 'sidekiq-limit_fetch'
|
||||||
gem 'sprockets-rails'
|
gem 'sprockets-rails'
|
||||||
gem 'stimulus-rails'
|
gem 'stimulus-rails'
|
||||||
gem 'tailwindcss-rails'
|
gem 'tailwindcss-rails'
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,8 @@ GEM
|
||||||
fugit (~> 1.8, >= 1.11.1)
|
fugit (~> 1.8, >= 1.11.1)
|
||||||
globalid (>= 1.0.1)
|
globalid (>= 1.0.1)
|
||||||
sidekiq (>= 6.5.0)
|
sidekiq (>= 6.5.0)
|
||||||
|
sidekiq-limit_fetch (4.4.1)
|
||||||
|
sidekiq (>= 6)
|
||||||
simplecov (0.22.0)
|
simplecov (0.22.0)
|
||||||
docile (~> 1.1)
|
docile (~> 1.1)
|
||||||
simplecov-html (~> 0.11)
|
simplecov-html (~> 0.11)
|
||||||
|
|
@ -465,6 +467,7 @@ DEPENDENCIES
|
||||||
shrine (~> 3.6)
|
shrine (~> 3.6)
|
||||||
sidekiq
|
sidekiq
|
||||||
sidekiq-cron
|
sidekiq-cron
|
||||||
|
sidekiq-limit_fetch
|
||||||
simplecov
|
simplecov
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
stimulus-rails
|
stimulus-rails
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ class ReverseGeocodingJob < ApplicationJob
|
||||||
def perform(klass, id)
|
def perform(klass, id)
|
||||||
return unless REVERSE_GEOCODING_ENABLED
|
return unless REVERSE_GEOCODING_ENABLED
|
||||||
|
|
||||||
sleep 1 if PHOTON_API_HOST == 'photon.komoot.io'
|
rate_limit_for_photon_api
|
||||||
|
|
||||||
data_fetcher(klass, id).call
|
data_fetcher(klass, id).call
|
||||||
end
|
end
|
||||||
|
|
@ -16,4 +16,10 @@ class ReverseGeocodingJob < ApplicationJob
|
||||||
def data_fetcher(klass, id)
|
def data_fetcher(klass, id)
|
||||||
"ReverseGeocoding::#{klass.pluralize.camelize}::FetchData".constantize.new(id)
|
"ReverseGeocoding::#{klass.pluralize.camelize}::FetchData".constantize.new(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def rate_limit_for_photon_api
|
||||||
|
return unless PHOTON_API_HOST == 'photon.komoot.io'
|
||||||
|
|
||||||
|
sleep 1 if PHOTON_API_HOST == 'photon.komoot.io'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,5 @@ end
|
||||||
Sidekiq.configure_client do |config|
|
Sidekiq.configure_client do |config|
|
||||||
config.redis = { url: ENV['REDIS_URL'] }
|
config.redis = { url: ENV['REDIS_URL'] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Sidekiq::Queue['reverse_geocoding'].limit = 1 if PHOTON_API_HOST == 'photon.komoot.io'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue