Module: Qless::Middleware::RedisReconnect
- Defined in:
- lib/qless/middleware/redis_reconnect.rb
Overview
A module for reconnecting to redis for each job
Class Method Summary collapse
Class Method Details
.new(*redis_connections, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/qless/middleware/redis_reconnect.rb', line 7 def self.new(*redis_connections, &block) Module.new do define_singleton_method :to_s do 'Qless::Middleware::RedisReconnect' end define_singleton_method(:inspect, method(:to_s)) block ||= ->(job) { redis_connections } define_method :around_perform do |job| Array(block.call(job)).each do |redis| redis.client.reconnect end super(job) end end end |