amqp 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
+ require File.expand_path('../lib/amqp/version', __FILE__)
2
+
1
3
  spec = Gem::Specification.new do |s|
2
4
  s.name = 'amqp'
3
- s.version = '0.6.6'
5
+ s.version = AMQP::VERSION
4
6
  s.date = '2009-12-29'
5
7
  s.summary = 'AMQP client implementation in Ruby/EventMachine'
6
8
  s.email = "amqp@tmm1.net"
@@ -51,6 +53,7 @@ spec = Gem::Specification.new do |s|
51
53
  "examples/mq/primes.rb",
52
54
  "examples/mq/stocks.rb",
53
55
  "lib/amqp.rb",
56
+ "lib/amqp/version.rb",
54
57
  "lib/amqp/buffer.rb",
55
58
  "lib/amqp/client.rb",
56
59
  "lib/amqp/frame.rb",
@@ -1,16 +1,11 @@
1
- module AMQP
2
- VERSION = '0.5.9'
3
-
4
- DIR = File.expand_path(File.dirname(File.expand_path(__FILE__)))
5
- $:.unshift DIR
6
-
7
- require 'ext/em'
8
- require 'ext/blankslate'
1
+ require File.expand_path('../ext/em', __FILE__)
2
+ require File.expand_path('../ext/blankslate', __FILE__)
9
3
 
10
- %w[ buffer spec protocol frame client ].each do |file|
11
- require "amqp/#{file}"
12
- end
4
+ %w[ version buffer spec protocol frame client ].each do |file|
5
+ require File.expand_path("../amqp/#{file}", __FILE__)
6
+ end
13
7
 
8
+ module AMQP
14
9
  class << self
15
10
  @logging = false
16
11
  attr_accessor :logging
@@ -1,4 +1,4 @@
1
- require 'amqp/frame'
1
+ require File.expand_path('../frame', __FILE__)
2
2
 
3
3
  module AMQP
4
4
  class Error < StandardError; end
@@ -1,6 +1,6 @@
1
- require 'amqp/spec'
2
- require 'amqp/buffer'
3
- require 'amqp/protocol'
1
+ require File.expand_path('../spec', __FILE__)
2
+ require File.expand_path('../buffer', __FILE__)
3
+ require File.expand_path('../protocol', __FILE__)
4
4
 
5
5
  module AMQP
6
6
  class Frame #:nodoc: all
@@ -121,4 +121,4 @@ if $0 =~ /bacon/ or $0 == __FILE__
121
121
  copy.should == orig
122
122
  end
123
123
  end
124
- end
124
+ end
@@ -1,5 +1,5 @@
1
- require 'amqp/spec'
2
- require 'amqp/buffer'
1
+ require File.expand_path('../spec', __FILE__)
2
+ require File.expand_path('../buffer', __FILE__)
3
3
 
4
4
  module AMQP
5
5
  module Protocol
@@ -209,4 +209,4 @@ if $0 =~ /bacon/ or $0 == __FILE__
209
209
  Protocol::Header.new(orig.to_binary).should == orig
210
210
  end
211
211
  end
212
- end
212
+ end
@@ -1,4 +1,4 @@
1
- require 'amqp/frame'
1
+ require File.expand_path('../frame', __FILE__)
2
2
 
3
3
  module AMQP
4
4
  module Server
@@ -96,4 +96,4 @@ if __FILE__ == $0
96
96
  EM.run{
97
97
  AMQP::Server.start
98
98
  }
99
- end
99
+ end
@@ -0,0 +1,3 @@
1
+ module AMQP
2
+ VERSION = '0.6.7'
3
+ end
data/lib/mq.rb CHANGED
@@ -740,6 +740,7 @@ class MQ
740
740
  end
741
741
 
742
742
  def prefetch(size)
743
+ @prefetch_size = size
743
744
  send Protocol::Basic::Qos.new(:prefetch_size => 0, :prefetch_count => size, :global => false)
744
745
  self
745
746
  end
@@ -807,6 +808,8 @@ class MQ
807
808
  qus = @queues
808
809
  @queues = {}
809
810
  qus.each{ |_,q| q.reset } if qus
811
+
812
+ prefetch(@prefetch_size) if @prefetch_size
810
813
  end
811
814
 
812
815
  private
@@ -30,14 +30,14 @@ class MQ
30
30
  #
31
31
  # Marshalling and unmarshalling the objects is handled internally. This
32
32
  # marshalling is subject to the same restrictions as defined in the
33
- # Marshal[http://ruby-doc.org/core/classes/Marshal.html] standard
33
+ # Marshal[http://ruby-doc.org/core/classes/Marshal.html] standard
34
34
  # library. See that documentation for further reference.
35
35
  #
36
- # When the optional object is not passed, the returned rpc reference is
37
- # used to send messages and arguments to the queue. See #method_missing
38
- # which does all of the heavy lifting with the proxy. Some client
39
- # elsewhere must call this method *with* the optional block so that
40
- # there is a valid destination. Failure to do so will just enqueue
36
+ # When the optional object is not passed, the returned rpc reference is
37
+ # used to send messages and arguments to the queue. See #method_missing
38
+ # which does all of the heavy lifting with the proxy. Some client
39
+ # elsewhere must call this method *with* the optional block so that
40
+ # there is a valid destination. Failure to do so will just enqueue
41
41
  # marshalled messages that are never consumed.
42
42
  #
43
43
  def initialize mq, queue, obj = nil
@@ -53,7 +53,7 @@ class MQ
53
53
  else
54
54
  obj
55
55
  end
56
-
56
+
57
57
  @mq.queue(queue).subscribe(:ack=>true){ |info, request|
58
58
  method, *args = ::Marshal.load(request)
59
59
  ret = @obj.__send__(method, *args)
@@ -67,7 +67,7 @@ class MQ
67
67
  else
68
68
  @callbacks ||= {}
69
69
  # XXX implement and use queue(nil)
70
- @queue = @mq.queue(@name = "random identifier #{::Kernel.rand(999_999_999_999)}").subscribe{|info, msg|
70
+ @queue = @mq.queue(@name = "random identifier #{::Kernel.rand(999_999_999_999)}", :auto_delete => true).subscribe{|info, msg|
71
71
  if blk = @callbacks.delete(info.message_id)
72
72
  blk.call ::Marshal.load(msg)
73
73
  end
@@ -97,4 +97,4 @@ class MQ
97
97
  @remote.publish(::Marshal.dump([meth, *args]), :reply_to => blk ? @name : nil, :message_id => message_id)
98
98
  end
99
99
  end
100
- end
100
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amqp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
@@ -62,6 +62,7 @@ files:
62
62
  - examples/mq/primes.rb
63
63
  - examples/mq/stocks.rb
64
64
  - lib/amqp.rb
65
+ - lib/amqp/version.rb
65
66
  - lib/amqp/buffer.rb
66
67
  - lib/amqp/client.rb
67
68
  - lib/amqp/frame.rb