Sha256: 266c9e44d982b8d34b735b5c6720981e45873c4f5e53ae9caf67c82bbf65782a

Contents?: true

Size: 1.9 KB

Versions: 53

Compression:

Stored size: 1.9 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 "test-job-fork"
  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
  queue "test-fail-job-fork"
  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

class TestJobMultithreadFork
  include Backburner::Queue
  queue "test-job-multithread-fork"
  queue_priority 1000
  def self.perform(x, y)
    sleep 1 # simluate work
    Backburner::Workers::ThreadsOnFork.enqueue ResponseJob, [{
        :worker_test_count_set => x + y
    }], :queue => 'response'
  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
backburner-allq-1.0.50 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.49 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.48 test/fixtures/test_fork_jobs.rb
backburner-1.6.1 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.47 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.46 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.45 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.44 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.40 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.39 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.38 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.37 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.36 test/fixtures/test_fork_jobs.rb
backburner-1.6.0 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.35 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.34 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.33 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.32 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.31 test/fixtures/test_fork_jobs.rb
backburner-allq-1.0.29 test/fixtures/test_fork_jobs.rb