Sha256: 3fc3b05a61bb68c4f2baba884590bb4203f8f579c8fe236529dbbf943f366e0f

Contents?: true

Size: 1007 Bytes

Versions: 19

Compression:

Stored size: 1007 Bytes

Contents

$:.unshift File.dirname(__FILE__) + '/../../lib'
require 'mq'

AMQP.start(:host => 'localhost') do

  def log *args
    p args
  end

  # AMQP.logging = true

  class HashTable < Hash
    def get key
      log 'HashTable', :get, key
      self[key]
    end
    
    def set key, value
      log 'HashTable', :set, key => value
      self[key] = value
    end

    def keys
      log 'HashTable', :keys
      super
    end
  end

  server = MQ.new.rpc('hash table node', HashTable.new)

  client = MQ.new.rpc('hash table node')
  client.set(:now, time = Time.now)
  client.get(:now) do |res|
    log 'client', :now => res, :eql? => res == time
  end

  client.set(:one, 1)
  client.keys do |res|
    log 'client', :keys => res
    AMQP.stop{ EM.stop }
  end

end

__END__

["HashTable", :set, {:now=>Thu Jul 17 21:04:53 -0700 2008}]
["HashTable", :get, :now]
["HashTable", :set, {:one=>1}]
["HashTable", :keys]
["client", {:eql?=>true, :now=>Thu Jul 17 21:04:53 -0700 2008}]
["client", {:keys=>[:one, :now]}]

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
adamh-amqp-0.6.3.1 examples/mq/hashtable.rb
brontes3d-amqp-0.6.4.0 examples/mq/hashtable.rb
brontes3d-amqp-0.6.4.1 examples/mq/hashtable.rb
brontes3d-amqp-0.6.4.2 examples/mq/hashtable.rb
brontes3d-amqp-0.6.4.3 examples/mq/hashtable.rb
brontes3d-amqp-0.6.4 examples/mq/hashtable.rb
fotonauts-amqp-0.6.1 examples/mq/hashtable.rb
fotonauts-amqp-0.6.4 examples/mq/hashtable.rb
tmm1-amqp-0.6.1 examples/mq/hashtable.rb
tmm1-amqp-0.6.3 examples/mq/hashtable.rb
tmm1-amqp-0.6.4 examples/mq/hashtable.rb
amqp-0.7.0.pre examples/mq/hashtable.rb
totty-amqp-0.6.7.1 examples/mq/hashtable.rb
totty-amqp-0.6.7.1.totty examples/mq/hashtable.rb
brontes3d-amqp-0.6.7.1 examples/mq/hashtable.rb
amqp-0.6.7 examples/mq/hashtable.rb
amqp-0.6.6 examples/mq/hashtable.rb
amqp-0.6.5 examples/mq/hashtable.rb
amqp-0.6.4 examples/mq/hashtable.rb