Sha256: bcb3e864f8060ac72fd0b6368df7483747cd19cccf555abccbe1f91acce3d27d

Contents?: true

Size: 1011 Bytes

Versions: 36

Compression:

Stored size: 1011 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8

require "bundler"
Bundler.setup

$:.unshift(File.expand_path("../../../lib", __FILE__))
require 'amqp'


def log(*args)
  p args
end

# AMQP.logging = true

class HashTable < Hash
  def get(key)
    self[key]
  end

  def set(key, value)
    self[key] = value
  end

  def keys
    super
  end
end

AMQP.start(:host => 'localhost') do |connection|
  trap(:INT) do
    unless connection.closing?
      connection.close { exit! }
    end
  end

  channel = AMQP::Channel.new(connection)
  server  = channel.rpc('hash table node', HashTable.new)
  client  = channel.rpc('hash table node')

  client.set(:protocol, "amqp")
  client.get(:protocol) do |res|
    log 'client', :protocol_get_res => res
  end

  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
  end

  EM.add_timer(3, Proc.new {
    AMQP.stop { EM.stop }
  })
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
amqp-0.9.10 examples/legacy/hashtable.rb
amqp-0.9.9 examples/legacy/hashtable.rb
amqp-0.9.8 examples/legacy/hashtable.rb
amqp-0.9.7 examples/legacy/hashtable.rb
amqp-0.9.6 examples/legacy/hashtable.rb
amqp-0.9.5 examples/legacy/hashtable.rb
amqp-0.9.4 examples/legacy/hashtable.rb
amqp-0.9.3 examples/legacy/hashtable.rb
amqp-0.9.2 examples/legacy/hashtable.rb
amqp-0.9.1 examples/legacy/hashtable.rb
amqp-0.9.0 examples/legacy/hashtable.rb
amqp-0.9.0.pre3 examples/legacy/hashtable.rb
amqp-0.9.0.pre2 examples/legacy/hashtable.rb
amqp-0.9.0.pre1 examples/legacy/hashtable.rb
amqp-0.8.4 examples/legacy/hashtable.rb
amqp-0.8.3 examples/legacy/hashtable.rb
amqp-0.8.2 examples/legacy/hashtable.rb
amqp-0.8.1 examples/legacy/hashtable.rb
amqp-0.8.0 examples/legacy/hashtable.rb
amqp-0.8.0.rc15 examples/legacy/hashtable.rb