Sha256: ac8f2140fb0d3c3009c8527be565dcfde7e3ad673de3bf96d3156d028f318e6e

Contents?: true

Size: 1.04 KB

Versions: 33

Compression:

Stored size: 1.04 KB

Contents

module Delayed
  module Plugins
    #
    # Add callbacks to the lifecycle to capture two main aspects
    # 1. When are workers checking in
    # 2. How long jobs are taking
    #
    class TimeKeeper < Plugin
      callbacks do |lifecycle|
        lifecycle.before(:perform) do |_worker, job|
          job.worker.start
        rescue StandardError => error
          App47Logger.log_warn 'before job perform', error
        end
        lifecycle.after(:perform) do |_worker, job|
          job.worker.record_job(job)
        rescue StandardError => error
          App47Logger.log_warn 'after job perform', error
        end
        lifecycle.before(:loop) do
          Delayed::Jobs::Worker.find_or_create_server.check_in
        rescue StandardError => error
          App47Logger.log_warn 'before worker loop', error
        end
        lifecycle.after(:loop) do
          Delayed::Jobs::Worker.find_or_create_server.check_in
        rescue StandardError => error
          App47Logger.log_warn 'after worker loop', error
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
web47core-3.2.20 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.19 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.18 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.17 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.16 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.15 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.14 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.13 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.12 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.9 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.8 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.7 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.6 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.5 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.4 lib/app/models/delayed/plugins/time_keeper.rb
web47core-2.2.20 lib/app/models/delayed/plugins/time_keeper.rb
web47core-2.2.19 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.3 lib/app/models/delayed/plugins/time_keeper.rb
web47core-3.2.2 lib/app/models/delayed/plugins/time_keeper.rb
web47core-2.2.15 lib/app/models/delayed/plugins/time_keeper.rb