mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-21 15:54:22 +01:00
(fix) replaces custom ServerLocale middleware with sidekiq i18n middleware
This commit is contained in:
parent
7e2b4593f5
commit
835f3b6ec3
@ -10,6 +10,7 @@
|
|||||||
- do not log Notifications#polling action anymore, by default, can be enable via env variable ENABLE_NOTIFICATIONS_POLLING_LOGGING=true
|
- do not log Notifications#polling action anymore, by default, can be enable via env variable ENABLE_NOTIFICATIONS_POLLING_LOGGING=true
|
||||||
- Fix a bug: api/products/index bug when sorting by amount
|
- Fix a bug: api/products/index bug when sorting by amount
|
||||||
- adds a rake task to regenerate invoices by ids (see maintenance.rake)
|
- adds a rake task to regenerate invoices by ids (see maintenance.rake)
|
||||||
|
- Fix a bug: replaces custom ServerLocale middleware with sidekiq i18n middleware
|
||||||
|
|
||||||
## v6.2.0 2023 October 13
|
## v6.2.0 2023 October 13
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
require 'sidekiq'
|
require 'sidekiq'
|
||||||
require 'sidekiq-scheduler'
|
require 'sidekiq-scheduler'
|
||||||
require 'sidekiq/middleware/i18n'
|
require 'sidekiq/middleware/i18n'
|
||||||
require 'sidekiq/server_locale'
|
|
||||||
|
|
||||||
redis_host = ENV.fetch('REDIS_HOST', 'localhost')
|
redis_host = ENV.fetch('REDIS_HOST', 'localhost')
|
||||||
redis_url = "redis://#{redis_host}:6379"
|
redis_url = "redis://#{redis_host}:6379"
|
||||||
@ -11,11 +10,17 @@ redis_url = "redis://#{redis_host}:6379"
|
|||||||
Sidekiq.configure_server do |config|
|
Sidekiq.configure_server do |config|
|
||||||
config.redis = { url: redis_url }
|
config.redis = { url: redis_url }
|
||||||
|
|
||||||
|
# client_middleware is also configured in configure_server block
|
||||||
|
# because jobs running in the Sidekiq server can themselves push
|
||||||
|
# new jobs to Sidekiq, thus acting as clients
|
||||||
|
# see https://github.com/sidekiq/sidekiq/wiki/Middleware for more details
|
||||||
config.client_middleware do |chain|
|
config.client_middleware do |chain|
|
||||||
|
chain.add Sidekiq::Middleware::I18n::Client
|
||||||
chain.add SidekiqUniqueJobs::Middleware::Client
|
chain.add SidekiqUniqueJobs::Middleware::Client
|
||||||
end
|
end
|
||||||
|
|
||||||
config.server_middleware do |chain|
|
config.server_middleware do |chain|
|
||||||
|
chain.add Sidekiq::Middleware::I18n::Server
|
||||||
chain.add SidekiqUniqueJobs::Middleware::Server
|
chain.add SidekiqUniqueJobs::Middleware::Server
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -36,11 +41,9 @@ Sidekiq.configure_client do |config|
|
|||||||
config.redis = { url: redis_url }
|
config.redis = { url: redis_url }
|
||||||
|
|
||||||
config.client_middleware do |chain|
|
config.client_middleware do |chain|
|
||||||
|
chain.add Sidekiq::Middleware::I18n::Client
|
||||||
chain.add SidekiqUniqueJobs::Middleware::Client
|
chain.add SidekiqUniqueJobs::Middleware::Client
|
||||||
end
|
end
|
||||||
config.server_middleware do |chain|
|
|
||||||
chain.add FabManager::Middleware::ServerLocale
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Quieting logging in the test environment
|
# Quieting logging in the test environment
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# module definition
|
|
||||||
module FabManager::Middleware; end
|
|
||||||
|
|
||||||
# Provides localization in workers
|
|
||||||
class FabManager::Middleware::ServerLocale
|
|
||||||
def call(_worker_class, job, _queue)
|
|
||||||
locale = job['locale'] || Rails.application.secrets.rails_locale
|
|
||||||
I18n.with_locale(locale) do
|
|
||||||
yield
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user