Sha256: 1b4bb98309863bd25f64491940e18b3e3a71832df5680828cd08fce683190afe

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

$:.unshift('lib')

require 'rubygems'
require 'ruote/engine'
require 'ruote/worker'
require 'ruote/part/storage_participant'
require 'ruote/storage/hash_storage'
require 'ruote/storage/fs_storage'

opts = {}

storage = if ARGV.include?('--fs')
  #FileUtils.rm_rf('work_mega') if ARGV.include?('-e')
  Ruote::FsStorage.new('work_mega', opts)
else
  Ruote::HashStorage.new(opts)
end

p storage.class

if ARGV.include?('-e')
  #
  # engine and worker
  #

  puts "... engine + worker ..."

  engine = Ruote::Engine.new(Ruote::Worker.new(storage))

  engine.register_participant 'alpha', Ruote::StorageParticipant

  start = Time.now

  pdef = Ruote.process_definition :name => 'mega' do
    #echo '/${f:index}/'
    alpha :unless => '${f:index} == 2000'
  end

  wfid = nil

  (1..2000).to_a.each_with_index do |i|
    wfid = engine.launch(pdef, 'index' => i)
  end

  puts "took #{Time.now - start} seconds to launch"

  #engine.context.worker.run_thread.join
  engine.wait_for(wfid)

else
  #
  # pure worker
  #

  puts "... standalone worker ..."

  worker = Ruote::Worker.new(storage)
  worker.run

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruote-2.3.0.3 test/bm/mega.rb
ruote-2.3.0.2 test/bm/mega.rb
ruote-2.3.0.1 test/bm/mega.rb
ruote-2.3.0 test/bm/mega.rb