amqp 0.5.9 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mq/rpc.rb CHANGED
@@ -1,5 +1,45 @@
1
1
  class MQ
2
+ # Basic RPC (remote procedure call) facility.
3
+ #
4
+ # Needs more detail and explanation.
5
+ #
6
+ # EM.run do
7
+ # server = MQ.rpc('hash table node', Hash)
8
+ #
9
+ # client = MQ.rpc('hash table node')
10
+ # client[:now] = Time.now
11
+ # client[:one] = 1
12
+ #
13
+ # client.values do |res|
14
+ # p 'client', :values => res
15
+ # end
16
+ #
17
+ # client.keys do |res|
18
+ # p 'client', :keys => res
19
+ # EM.stop_event_loop
20
+ # end
21
+ # end
22
+ #
2
23
  class RPC < BlankSlate
24
+ # Takes a channel, queue and optional object.
25
+ #
26
+ # The optional object may be a class name, module name or object
27
+ # instance. When given a class or module name, the object is instantiated
28
+ # during this setup. The passed queue is automatically subscribed to so
29
+ # it passes all messages (and their arguments) to the object.
30
+ #
31
+ # Marshalling and unmarshalling the objects is handled internally. This
32
+ # marshalling is subject to the same restrictions as defined in the
33
+ # Marshal[http://ruby-doc.org/core/classes/Marshal.html] standard
34
+ # library. See that documentation for further reference.
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
41
+ # marshalled messages that are never consumed.
42
+ #
3
43
  def initialize mq, queue, obj = nil
4
44
  @mq = mq
5
45
  @mq.rpcs[queue] ||= self
@@ -34,6 +74,20 @@ class MQ
34
74
  end
35
75
  end
36
76
 
77
+ # Calling MQ.rpc(*args) returns a proxy object without any methods beyond
78
+ # those in Object. All calls to the proxy are handled by #method_missing which
79
+ # works to marshal and unmarshal all method calls and their arguments.
80
+ #
81
+ # EM.run do
82
+ # server = MQ.rpc('hash table node', Hash)
83
+ # client = MQ.rpc('hash table node')
84
+ #
85
+ # # calls #method_missing on #[] which marshals the method name and
86
+ # # arguments to publish them to the remote
87
+ # client[:now] = Time.now
88
+ # ....
89
+ # end
90
+ #
37
91
  def method_missing meth, *args, &blk
38
92
  # XXX use uuids instead
39
93
  message_id = "random message id #{::Kernel.rand(999_999_999_999)}"
data/protocol/codegen.rb CHANGED
@@ -12,6 +12,7 @@ s = JSON.parse(File.read(path))
12
12
  require 'erb'
13
13
 
14
14
  puts ERB.new(%q[
15
+ #:stopdoc:
15
16
  # this file was autogenerated on <%= Time.now.to_s %>
16
17
  # using <%= name.ljust(16) %> (mtime: <%= File.mtime(path) %>)
17
18
  #
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.5.9
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-01 00:00:00 -07:00
12
+ date: 2009-01-09 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.12.0
23
+ version: 0.12.2
24
24
  version:
25
25
  description: AMQP client implementation in Ruby/EventMachine
26
26
  email: amqp@tmm1.net
@@ -28,8 +28,8 @@ executables: []
28
28
 
29
29
  extensions: []
30
30
 
31
- extra_rdoc_files: []
32
-
31
+ extra_rdoc_files:
32
+ - README
33
33
  files:
34
34
  - README
35
35
  - examples/amqp/simple.rb
@@ -39,6 +39,8 @@ files:
39
39
  - examples/mq/pingpong.rb
40
40
  - examples/mq/primes-simple.rb
41
41
  - examples/mq/primes.rb
42
+ - examples/mq/simple-ack.rb
43
+ - examples/mq/simple-get.rb
42
44
  - examples/mq/simple.rb
43
45
  - examples/mq/stocks.rb
44
46
  - lib/amqp/buffer.rb
@@ -51,6 +53,7 @@ files:
51
53
  - lib/ext/em.rb
52
54
  - lib/ext/emfork.rb
53
55
  - lib/mq/exchange.rb
56
+ - lib/mq/header.rb
54
57
  - lib/mq/logger.rb
55
58
  - lib/mq/queue.rb
56
59
  - lib/mq/rpc.rb
@@ -59,7 +62,7 @@ files:
59
62
  - protocol/codegen.rb
60
63
  - protocol/doc.txt
61
64
  - protocol/amqp-0.8.xml
62
- has_rdoc: false
65
+ has_rdoc: true
63
66
  homepage: http://amqp.rubyforge.org/
64
67
  post_install_message:
65
68
  rdoc_options: []
@@ -81,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
84
  requirements: []
82
85
 
83
86
  rubyforge_project:
84
- rubygems_version: 1.2.0
87
+ rubygems_version: 1.3.0
85
88
  signing_key:
86
89
  specification_version: 2
87
90
  summary: AMQP client implementation in Ruby/EventMachine