Sha256: 23284563147eb960d5544a91b6f0ccc95d9f81eac58a3c9b1d4382391eaa9622

Contents?: true

Size: 1 KB

Versions: 13

Compression:

Stored size: 1 KB

Contents

#!/usr/bin/env ruby
current_dir = File.dirname(File.expand_path(__FILE__))
lib_path = File.join(current_dir, '..', 'lib')
$LOAD_PATH.unshift lib_path

require 'journeta'
include Journeta
include Journeta::Common
include Journeta::Common::Shutdown

class JobProcessor
  def call(msg)
    if msg.class == Job && !msg.submission
      puts "Processing job ##{msg.name} from peer ##{msg.owner}."
    end
  end
end

peer_port = (2048 + rand( 2 ** 8))
journeta = Journeta::Engine.new(:peer_port => peer_port, :peer_handler => JobProcessor.new, :groups => ['queue_example'])
stop_on_shutdown(journeta)
journeta.start


# Keep creating random jobs.
puts "Don't forget to start a server at some point! CTRL-C to exit this client."
while true
  num = rand(1024)
  puts "Creating random job ##{num}."
  job = Job.new
  job.owner = journeta.uuid
  job.name = num
  job.description = 'whatever'
  job.data = 'Anything YAML serializable!'
  job.submission = true
  journeta.send_to_known_peers(job) # All servers will get it.
  sleep 4
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
journeta-1.1.0 bin/journeta_queue_client.rb
journeta-1.0.1 bin/journeta_queue_client.rb
journeta-1.0.0 bin/journeta_queue_client.rb
journeta-0.2.2 bin/journeta_queue_client.rb
journeta-0.2.1 bin/journeta_queue_client.rb
journeta-0.2.0 bin/journeta_queue_client.rb
journeta-0.1.1 examples/queue_client.rb
journeta-0.1.0 examples/queue_client.rb
journeta-0.1.3 examples/queue_client.rb
journeta-0.1.7 examples/queue_client.rb
journeta-0.1.4 examples/queue_client.rb
journeta-0.1.2 examples/queue_client.rb
journeta-0.1.6 examples/queue_client.rb