Sha256: 0ba4a4af82534e01f7d1122ded8ee0a21ef5459b0e4ecb7f212427aaff215c44
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
require 'delayed/heartbeat/compatibility' require 'delayed/heartbeat/configuration' require 'delayed/heartbeat/delete_worker_results' require 'delayed/heartbeat/plugin' require 'delayed/heartbeat/version' require 'delayed/heartbeat/worker' require 'delayed/heartbeat/worker_heartbeat' require 'delayed/heartbeat/railtie' if defined?(Rails::Railtie) module Delayed module Heartbeat @configuration = Delayed::Heartbeat::Configuration.new class << self def configure yield(configuration) if block_given? end def configuration @configuration end def delete_workers_with_different_version(current_version = configuration.worker_version) old_workers = Delayed::Heartbeat::Worker.workers_with_different_version(current_version) cleanup_workers(old_workers, mark_attempt_failed: false) end def delete_timed_out_workers(timeout_seconds = configuration.heartbeat_timeout_seconds) dead_workers = Delayed::Heartbeat::Worker.dead_workers(timeout_seconds) cleanup_workers(dead_workers, mark_attempt_failed: true) end private def cleanup_workers(workers, mark_attempt_failed: true) Delayed::Heartbeat::Worker.transaction do worker_job_map = workers.each_with_object(Hash.new) do |worker, worker_job_map| worker_job_map[worker] = worker.unlock_jobs(mark_attempt_failed: mark_attempt_failed) end Delayed::Heartbeat::Worker.delete_workers(workers) Delayed::Heartbeat::DeleteWorkerResults.new(worker_job_map) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
delayed_job_heartbeat_plugin-0.2.0 | lib/delayed/heartbeat.rb |