Sha256: 39249f404b2805924a2be5ae0017f4a36458f571d167cdf60ff4fd6880a0d80d

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
delayed_job_heartbeat_plugin-0.2.0 lib/delayed/heartbeat/configuration.rb
delayed_job_heartbeat_plugin-0.1.0 lib/delayed/heartbeat/configuration.rb