mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -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 'sidekiq'
|
||||
gem 'sidekiq-cron'
|
||||
gem 'sidekiq-limit_fetch'
|
||||
gem 'sprockets-rails'
|
||||
gem 'stimulus-rails'
|
||||
gem 'tailwindcss-rails'
|
||||
|
|
|
|||
|
|
@ -370,6 +370,8 @@ GEM
|
|||
fugit (~> 1.8, >= 1.11.1)
|
||||
globalid (>= 1.0.1)
|
||||
sidekiq (>= 6.5.0)
|
||||
sidekiq-limit_fetch (4.4.1)
|
||||
sidekiq (>= 6)
|
||||
simplecov (0.22.0)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
|
|
@ -465,6 +467,7 @@ DEPENDENCIES
|
|||
shrine (~> 3.6)
|
||||
sidekiq
|
||||
sidekiq-cron
|
||||
sidekiq-limit_fetch
|
||||
simplecov
|
||||
sprockets-rails
|
||||
stimulus-rails
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class ReverseGeocodingJob < ApplicationJob
|
|||
def perform(klass, id)
|
||||
return unless REVERSE_GEOCODING_ENABLED
|
||||
|
||||
sleep 1 if PHOTON_API_HOST == 'photon.komoot.io'
|
||||
rate_limit_for_photon_api
|
||||
|
||||
data_fetcher(klass, id).call
|
||||
end
|
||||
|
|
@ -16,4 +16,10 @@ class ReverseGeocodingJob < ApplicationJob
|
|||
def data_fetcher(klass, id)
|
||||
"ReverseGeocoding::#{klass.pluralize.camelize}::FetchData".constantize.new(id)
|
||||
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
|
||||
|
|
|
|||
|
|
@ -24,3 +24,5 @@ end
|
|||
Sidekiq.configure_client do |config|
|
||||
config.redis = { url: ENV['REDIS_URL'] }
|
||||
end
|
||||
|
||||
Sidekiq::Queue['reverse_geocoding'].limit = 1 if PHOTON_API_HOST == 'photon.komoot.io'
|
||||
|
|
|
|||
Loading…
Reference in a new issue