Sha256: 8e007f41283feebb33758e0955c27d184f57896d982d9afd4657f34293e3b9c5
Contents?: true
Size: 1.41 KB
Versions: 33
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true module Delayed module Jobs # # Hold the job metric information for a specific job, used to determine if the job should be auto restarted # class Metric include StandardModel # # Fields # field :name, type: String field :count, type: Integer, default: 0 field :max, type: Float, default: 0 field :min, type: Float, default: 1_000_000_000 field :total, type: Float, default: 0 field :last_run_at, type: Time # # Validations # validates :name, uniqueness: true, presence: true # # Max allowed time for a currently running job # def max_allowed_seconds send(max_allowed_method) * max_allowed_factor rescue StandardError max * 5 end # # Return the average time to run this job # def avg count.zero? ? 0 : total / count rescue StandardError 0 end private # # Pull the method from system configuration to evalutate max allowed time # def max_allowed_method @max_allowed_method ||= SystemConfiguration.delayed_job_max_allowed_method end # # Pull the factor for max allowed when evaluating allowed time # def max_allowed_factor @max_allowed_factor ||= SystemConfiguration.delayed_job_max_allowed_factor end end end end
Version data entries
33 entries across 33 versions & 1 rubygems