Sha256: c82b5d2338e0b6a0e4f9ae6e56caed959e243196b9cc7e4b8c2211c4de9918eb
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
# frozen_string_literal: true 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 attr_reader :configuration 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, result| result[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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
delayed_job_heartbeat_plugin-0.6.0 | lib/delayed/heartbeat.rb |
delayed_job_heartbeat_plugin-0.5.0 | lib/delayed/heartbeat.rb |
delayed_job_heartbeat_plugin-0.4.0 | lib/delayed/heartbeat.rb |