Sha256: a592036092e12034111ca16c0601548dee5fa1f114ab01b2af17fda806e0c494
Contents?: true
Size: 1.03 KB
Versions: 12
Compression:
Stored size: 1.03 KB
Contents
module WorkerExamples let(:env) { Asynchronic::Environment.new queue_engine, data_store } let(:queue_name) { :test_worker } let(:queue) { env.queue queue_name } def enqueue_processes processes = 5.times.map do env.create_process(WorkerJob, queue: :test_worker).tap(&:enqueue) end queue.must_enqueued processes processes.each { |p| p.must_be :queued? } processes end it 'Instance usage' do worker = Asynchronic::Worker.new :test_worker, env processes = enqueue_processes Thread.new do loop { break if queue.empty? } worker.stop end worker.start processes.each { |p| p.must_be :completed? } end it 'Class usage' do Asynchronic.configure do |config| config.queue_engine = queue_engine config.data_store = data_store end processes = enqueue_processes Asynchronic::Worker.start :test_worker do |worker| loop { break if worker.queue.empty? } worker.stop end processes.each { |p| p.must_be :completed? } end end
Version data entries
12 entries across 12 versions & 1 rubygems