What is the best practice for sharing a Redis connection pool between Rails and Sidekiq?
I did this in the initializer:
Sidekiq.configure_client do |config| pool = ConnectionPool.new(size: 1, timeout: 5) { Redis.new(host: redis_config['host'], port: redis_config['port'], db: redis_config['database']) } config.redis = pool Redis.current = pool end Sidekiq.configure_server do |config| pool = ConnectionPool.new(size: 10, timeout: 5) { Redis.new(host: redis_config['host'], port: redis_config['port'], db: redis_config['database']) } config.redis = pool Redis.current = pool config.server_middleware do |chain| chain.add Kiqstand::Middleware end end
But setting up the Rails Redis pool in the Sidekiq block is not very clean ... Any ideas?
source share