Sha256: 201f5bc98bc32fe19f4ff4e2806aaab07130ece88e8df562f3112450fc5137b6

Contents?: true

Size: 972 Bytes

Versions: 5

Compression:

Stored size: 972 Bytes

Contents

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

EM.run{

  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
    EM.stop_event_loop
  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

5 entries across 5 versions & 2 rubygems

Version Path
tmm1-amqp-0.5.1 examples/hashtable.rb
tmm1-amqp-0.5.2 examples/hashtable.rb
amqp-0.5.0 examples/hashtable.rb
amqp-0.5.1 examples/hashtable.rb
amqp-0.5.2 examples/hashtable.rb