Refactor (ruby) redis configuration (#31694)

This commit is contained in:
David Roetzel 2024-09-02 16:19:55 +02:00 committed by GitHub
parent a23b3747ac
commit 388d5473e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 295 additions and 90 deletions

View file

@ -101,7 +101,8 @@ module Mastodon
end
config.before_configuration do
require 'mastodon/redis_config'
require 'mastodon/redis_configuration'
::REDIS_CONFIGURATION = Mastodon::RedisConfiguration.new
config.x.use_vips = ENV['MASTODON_USE_LIBVIPS'] == 'true'

View file

@ -25,7 +25,7 @@ Rails.application.configure do
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS
config.cache_store = :redis_cache_store, REDIS_CONFIGURATION.cache
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}",
}

View file

@ -57,7 +57,7 @@ Rails.application.configure do
config.log_tags = [:request_id]
# Use a different cache store in production.
config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS
config.cache_store = :redis_cache_store, REDIS_CONFIGURATION.cache
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque

View file

@ -3,7 +3,7 @@
require_relative '../../lib/mastodon/sidekiq_middleware'
Sidekiq.configure_server do |config|
config.redis = REDIS_SIDEKIQ_PARAMS
config.redis = REDIS_CONFIGURATION.sidekiq
# This is used in Kubernetes setups, to signal that the Sidekiq process has started and will begin processing jobs
# This comes from https://github.com/sidekiq/sidekiq/wiki/Kubernetes#sidekiq
@ -51,7 +51,7 @@ Sidekiq.configure_server do |config|
end
Sidekiq.configure_client do |config|
config.redis = REDIS_SIDEKIQ_PARAMS
config.redis = REDIS_CONFIGURATION.sidekiq
config.client_middleware do |chain|
chain.add SidekiqUniqueJobs::Middleware::Client

View file

@ -3,6 +3,6 @@
require 'stoplight'
Rails.application.reloader.to_prepare do
Stoplight.default_data_store = Stoplight::DataStore::Redis.new(RedisConfiguration.new.connection)
Stoplight.default_data_store = Stoplight::DataStore::Redis.new(RedisConnection.new.connection)
Stoplight.default_notifiers = [Stoplight::Notifier::Logger.new(Rails.logger)]
end