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.8.0.rc14 examples/legacy/hashtable.rb
amqp-0.8.0.rc13 examples/legacy/hashtable.rb
amqp-0.8.0.rc12 examples/legacy/hashtable.rb
amqp-0.8.0.rc11 examples/legacy/hashtable.rb
amqp-0.8.0.rc10 examples/legacy/hashtable.rb
amqp-0.8.0.rc9 examples/legacy/hashtable.rb
amqp-0.8.0.rc8 examples/legacy/hashtable.rb
amqp-0.8.0.rc7 examples/legacy/hashtable.rb
amqp-0.8.0.rc6 examples/legacy/hashtable.rb
amqp-0.8.0.rc5 examples/legacy/hashtable.rb
amqp-0.8.0.rc4 examples/legacy/hashtable.rb
amqp-0.8.0.rc3 examples/legacy/hashtable.rb
amqp-0.8.0.rc2 examples/various/hashtable.rb
amqp-0.8.0.rc1 examples/various/hashtable.rb
amqp-0.8.0.pre.beta1 examples/various/hashtable.rb
amqp-0.8.0.beta1 examples/various/hashtable.rb