Sha256: ad1554df27b15d1891baf922010b05e43fb712e47ef8dc06094ebb03ce84393f

Contents?: true

Size: 745 Bytes

Versions: 19

Compression:

Stored size: 745 Bytes

Contents

require 'rubygems'
require 'lib/rufus/cloche'

CLO = Rufus::Cloche.new(:dir => 'cloche')

p $$

def process (task)
  puts "#{$$} . processing task #{task['_id']}"
  r = CLO.delete(task)
  if r
    puts "#{$$} x could not process task #{task['_id']}  ===================="
  else
    icon = task['_id'].match(/^#{$$}:/) ? 'o' : 'O'
    puts "#{$$} #{icon} processed task #{task['_id']}"
  end
end

loop do

  CLO.get_many('task').each { |task| process(task) }

  (rand * 12).to_i.times do |i|
    nt = {
      '_id' => "#{$$}:#{i}:#{(Time.now.to_f * 1000).to_i}",
      'type' => 'task'
    }
    t = CLO.put(nt)
    if t
      puts "#{$$} x new task #{nt['_id']} (failed)"
    else
      puts "#{$$} . new task #{nt['_id']}"
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rufus-cloche-1.0.2 test/ct_worker.rb
rufus-cloche-1.0.1 test/ct_worker.rb
rufus-cloche-1.0.0 test/ct_worker.rb
rufus-cloche-0.1.21 test/ct_worker.rb
rufus-cloche-0.1.20 test/ct_worker.rb
rufus-cloche-0.1.19 test/ct_worker.rb
rufus-cloche-0.1.18 test/ct_worker.rb
rufus-cloche-0.1.17 test/ct_worker.rb
rufus-cloche-0.1.16 test/ct_worker.rb
rufus-cloche-0.1.15 test/ct_worker.rb
rufus-cloche-0.1.14 test/ct_worker.rb
rufus-cloche-0.1.13 test/ct_worker.rb
rufus-cloche-0.1.12 test/ct_worker.rb
rufus-cloche-0.1.11 test/ct_worker.rb
rufus-cloche-0.1.10 test/ct_worker.rb
rufus-cloche-0.1.9 test/ct_worker.rb
rufus-cloche-0.1.8 test/ct_worker.rb
rufus-cloche-0.1.7 test/ct_worker.rb
rufus-cloche-0.1.6 test/ct_worker.rb