Sha256: e2067f858d9bd60eabf41f2a8ec943b1b809b3f417de419e9d6bba18d6025c67

Contents?: true

Size: 964 Bytes

Versions: 3

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module Delayed
  module Heartbeat
    class Configuration
      attr_accessor :enabled, :worker_label, :worker_version,
                    :heartbeat_timeout_seconds, :heartbeat_interval_seconds,
                    :worker_termination_enabled, :on_worker_termination
      alias_method :enabled?, :enabled
      alias_method :worker_termination_enabled?, :worker_termination_enabled

      def initialize(options = {})
        options.each do |key, value|
          send("#{key}=", value)
        end

        if enabled.nil?
          self.enabled = defined?(Rails) ? Rails.env.production? : true
        end

        if worker_termination_enabled.nil?
          self.worker_termination_enabled = defined?(Rails) ? Rails.env.production? : true
        end

        self.heartbeat_timeout_seconds ||= 180
        self.heartbeat_interval_seconds ||= 60
        self.on_worker_termination ||= Proc.new {}
      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/configuration.rb
delayed_job_heartbeat_plugin-0.5.0 lib/delayed/heartbeat/configuration.rb
delayed_job_heartbeat_plugin-0.4.0 lib/delayed/heartbeat/configuration.rb