Sha256: 4421b76b1312cd961eff9741199208cff0446d2c99d7258ac48bc4b919b62481

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

class ResponseJob
  include Backburner::Queue
  queue_priority 1000
  def self.perform(data)
    $worker_test_count += data['worker_test_count'].to_i if data['worker_test_count']
    $worker_success = data['worker_success'] if data['worker_success']
    $worker_test_count = data['worker_test_count_set'].to_i if data['worker_test_count_set']
    $worker_raise = data['worker_raise'] if data['worker_raise']
  end
end

class TestJobFork
  include Backburner::Queue
  queue_priority 1000
  def self.perform(x, y)
    Backburner::Workers::ThreadsOnFork.enqueue ResponseJob, [{
        :worker_test_count_set => x + y
    }], :queue => 'response'
  end
end

class TestFailJobFork
  include Backburner::Queue
  def self.perform(x, y)
    Backburner::Workers::ThreadsOnFork.enqueue ResponseJob, [{
       :worker_raise => true
    }], :queue => 'response'
  end
end

class TestRetryJobFork
  include Backburner::Queue
  def self.perform(x, y)
    $worker_test_count += 1

    if $worker_test_count <= 2
      Backburner::Workers::ThreadsOnFork.enqueue ResponseJob, [{
          :worker_test_count => 1
      }], :queue => 'response'

      raise RuntimeError
    else # succeeds
      Backburner::Workers::ThreadsOnFork.enqueue ResponseJob, [{
          :worker_test_count => 1,
          :worker_success => true
      }], :queue => 'response'
    end
  end
end

class TestAsyncJobFork
  include Backburner::Performable
  def self.foo(x, y)
    Backburner::Workers::ThreadsOnFork.enqueue ResponseJob, [{
        :worker_test_count_set => x * y
    }], :queue => 'response'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
backburner-0.3.4 test/fixtures/test_fork_jobs.rb
backburner-0.3.3 test/fixtures/test_fork_jobs.rb
backburner-0.3.2 test/fixtures/test_fork_jobs.rb
backburner-0.3.1 test/fixtures/test_fork_jobs.rb
backburner-0.3.0 test/fixtures/test_fork_jobs.rb