tmm1-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: tmm1-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
@@ -27,8 +27,8 @@ executables: []
27
27
 
28
28
  extensions: []
29
29
 
30
- extra_rdoc_files: []
31
-
30
+ extra_rdoc_files:
31
+ - README
32
32
  files:
33
33
  - README
34
34
  - examples/amqp/simple.rb
@@ -38,6 +38,8 @@ files:
38
38
  - examples/mq/pingpong.rb
39
39
  - examples/mq/primes-simple.rb
40
40
  - examples/mq/primes.rb
41
+ - examples/mq/simple-ack.rb
42
+ - examples/mq/simple-get.rb
41
43
  - examples/mq/simple.rb
42
44
  - examples/mq/stocks.rb
43
45
  - lib/amqp/buffer.rb
@@ -50,6 +52,7 @@ files:
50
52
  - lib/ext/em.rb
51
53
  - lib/ext/emfork.rb
52
54
  - lib/mq/exchange.rb
55
+ - lib/mq/header.rb
53
56
  - lib/mq/logger.rb
54
57
  - lib/mq/queue.rb
55
58
  - lib/mq/rpc.rb
@@ -58,7 +61,7 @@ files:
58
61
  - protocol/codegen.rb
59
62
  - protocol/doc.txt
60
63
  - protocol/amqp-0.8.xml
61
- has_rdoc: false
64
+ has_rdoc: true
62
65
  homepage: http://amqp.rubyforge.org/
63
66
  post_install_message:
64
67
  rdoc_options: []