Sha256: 6fae95aa8ff6e9566a350442d1d8fbb87b67fcd1318b5b2b0c038ac79dffda3e

Contents?: true

Size: 851 Bytes

Versions: 5

Compression:

Stored size: 851 Bytes

Contents

require "active_job/queue_adapter"

class MissionControl::Jobs::Server
  include MissionControl::Jobs::IdentifiedByName
  include Serializable, RecurringTasks, Workers

  attr_reader :name, :queue_adapter, :application, :backtrace_cleaner

  def initialize(name:, queue_adapter:, application:, backtrace_cleaner: nil)
    super(name: name)
    @queue_adapter = queue_adapter
    @application = application
    @backtrace_cleaner = backtrace_cleaner || MissionControl::Jobs.backtrace_cleaner
  end

  def activating(&block)
    previous_adapter = ActiveJob::Base.current_queue_adapter
    ActiveJob::Base.current_queue_adapter = queue_adapter
    queue_adapter.activating(&block)
  ensure
    ActiveJob::Base.current_queue_adapter = previous_adapter
  end

  def queue_adapter_name
    ActiveJob.adapter_name(queue_adapter).underscore.to_sym
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mission_control-jobs-1.0.1 lib/mission_control/jobs/server.rb
mission_control-jobs-1.0.0 lib/mission_control/jobs/server.rb
mission_control-jobs-0.6.0 lib/mission_control/jobs/server.rb
mission_control-jobs-0.5.0 lib/mission_control/jobs/server.rb
mission_control-jobs-0.4.0 lib/mission_control/jobs/server.rb