Sha256: 6ed37c5902d028974e4a0fcc1ebcd8ba3caffa8984484bb29a0754744401a0af
Contents?: true
Size: 846 Bytes
Versions: 2
Compression:
Stored size: 846 Bytes
Contents
module AtomicSidekiq module AtomicOperation class Heartbeat < Base HEARTBEAT_SCRIPT = File.read( File.join(File.dirname(__FILE__), "./lua_scripts/heartbeat.lua") ) def perform(jid:, timeout:) key = in_flight_job_key(jid) return unless key redis do |conn| conn.eval(HEARTBEAT_SCRIPT, [key], [expiration_date(timeout)]) end end private def expiration_date(timeout) Time.now.utc.to_i + timeout end def in_flight_job_key(jid) matcher = in_flight_keymaker.job_matcher(jid) it = 0 loop do it, keys = redis { |conn| conn.scan(it, match: matcher) } return keys[0] if keys.count > 0 it = it.to_i return if it.zero? end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
atomic-sidekiq-1.3.0 | lib/atomic_sidekiq/atomic_operation/heartbeat.rb |
atomic-sidekiq-1.2.0 | lib/atomic_sidekiq/atomic_operation/heartbeat.rb |