zmqmachine 0.6.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.gitignore +15 -0
  2. data/AUTHORS.txt +3 -0
  3. data/History.txt +19 -0
  4. data/examples/fake_ftp.rb +9 -1
  5. data/examples/one_handed_ping_pong.rb +2 -1
  6. data/examples/ping_pong.rb +2 -2
  7. data/examples/pub_sub.rb +10 -4
  8. data/examples/pubsub_forwarder.rb +8 -3
  9. data/examples/throttled_ping_pong.rb +2 -2
  10. data/lib/zm/configuration.rb +129 -0
  11. data/lib/zm/device.rb +4 -0
  12. data/lib/zm/device/configuration.rb +24 -0
  13. data/lib/zm/{devices → device}/forwarder.rb +48 -46
  14. data/lib/zm/{devices → device}/queue.rb +63 -44
  15. data/lib/zm/log_client.rb +2 -2
  16. data/lib/zm/log_server.rb +68 -0
  17. data/lib/zm/reactor.rb +42 -29
  18. data/lib/zm/server.rb +4 -0
  19. data/lib/zm/server/base.rb +139 -0
  20. data/lib/zm/server/configuration.rb +53 -0
  21. data/lib/zm/server/pair.rb +23 -0
  22. data/lib/zm/server/pub.rb +23 -0
  23. data/lib/zm/server/pull.rb +24 -0
  24. data/lib/zm/server/push.rb +23 -0
  25. data/lib/zm/server/rep.rb +42 -0
  26. data/lib/zm/server/req.rb +41 -0
  27. data/lib/zm/server/routing_envelope.rb +26 -0
  28. data/lib/zm/server/sub.rb +40 -0
  29. data/lib/zm/sockets.rb +1 -1
  30. data/lib/zm/sockets/base.rb +3 -12
  31. data/lib/zm/sockets/envelope_help.rb +49 -0
  32. data/lib/zm/sockets/pair.rb +0 -1
  33. data/lib/zm/sockets/pub.rb +0 -1
  34. data/lib/zm/sockets/rep.rb +45 -0
  35. data/lib/zm/sockets/req.rb +46 -1
  36. data/lib/zm/sockets/sub.rb +0 -1
  37. data/lib/zm/timers.rb +26 -13
  38. data/lib/zmqmachine.rb +1 -1
  39. data/version.txt +1 -1
  40. data/zmqmachine.gemspec +6 -6
  41. metadata +90 -91
  42. data/lib/zm/devices.rb +0 -4
  43. data/lib/zm/sockets/xrep.rb +0 -86
  44. data/lib/zm/sockets/xreq.rb +0 -86
@@ -1,4 +0,0 @@
1
-
2
- %w( forwarder queue ).each do |rb_file|
3
- require File.join(File.dirname(__FILE__), 'devices', rb_file)
4
- end
@@ -1,86 +0,0 @@
1
- #--
2
- #
3
- # Author:: Chuck Remes
4
- # Homepage:: http://github.com/chuckremes/zmqmachine
5
- # Date:: 20100602
6
- #
7
- #----------------------------------------------------------------------------
8
- #
9
- # Copyright (C) 2010 by Chuck Remes. All Rights Reserved.
10
- # Email: cremes at mac dot com
11
- #
12
- # (The MIT License)
13
- #
14
- # Permission is hereby granted, free of charge, to any person obtaining
15
- # a copy of this software and associated documentation files (the
16
- # 'Software'), to deal in the Software without restriction, including
17
- # without limitation the rights to use, copy, modify, merge, publish,
18
- # distribute, sublicense, and/or sell copies of the Software, and to
19
- # permit persons to whom the Software is furnished to do so, subject to
20
- # the following conditions:
21
- #
22
- # The above copyright notice and this permission notice shall be
23
- # included in all copies or substantial portions of the Software.
24
- #
25
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
26
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
29
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
- #
33
- #---------------------------------------------------------------------------
34
- #
35
- #
36
-
37
- module ZMQMachine
38
-
39
- module Socket
40
-
41
- class XRep
42
- include ZMQMachine::Socket::Base
43
-
44
- def initialize context, handler
45
- @poll_options = ZMQ::POLLIN
46
- @kind = :xreply
47
-
48
- super
49
- @state = :ready
50
- end
51
-
52
- # Attach a handler to the XREP socket.
53
- #
54
- # A XREP socket has no restrictions on the number of sends and
55
- # recieves. Each send will silently prepend a message part to
56
- # your outgoing data which the REQ/XREQ socket on the other end
57
- # will use for matching up the transaction.
58
- #
59
- # This socket expects its +handler+ to
60
- # implement at least the #on_readable method. This method
61
- # will be called whenever a reply arrives. The #on_writable method
62
- # will be called continually until the socket HWM is breached.
63
- #
64
- # For error handling purposes, the handler must also
65
- # implement #on_readable_error.
66
- #
67
- def on_attach handler
68
- raise ArgumentError, "Handler must implement an #on_readable method" unless handler.respond_to? :on_readable
69
- raise ArgumentError, "Handler must implement an #on_readable_error method" unless handler.respond_to? :on_readable_error
70
- raise ArgumentError, "Handler must implement an #on_readable method" unless handler.respond_to? :on_writable
71
- raise ArgumentError, "Handler must implement an #on_readable_error method" unless handler.respond_to? :on_writable_error
72
- super
73
- end
74
-
75
-
76
- private
77
-
78
- def allocate_socket context
79
- sock = ZMQ::Socket.new context.pointer, ZMQ::XREP
80
- sock
81
- end
82
- end # class XRep
83
-
84
- end # module Socket
85
-
86
- end # module ZMQMachine
@@ -1,86 +0,0 @@
1
- #--
2
- #
3
- # Author:: Chuck Remes
4
- # Homepage:: http://github.com/chuckremes/zmqmachine
5
- # Date:: 20100602
6
- #
7
- #----------------------------------------------------------------------------
8
- #
9
- # Copyright (C) 2010 by Chuck Remes. All Rights Reserved.
10
- # Email: cremes at mac dot com
11
- #
12
- # (The MIT License)
13
- #
14
- # Permission is hereby granted, free of charge, to any person obtaining
15
- # a copy of this software and associated documentation files (the
16
- # 'Software'), to deal in the Software without restriction, including
17
- # without limitation the rights to use, copy, modify, merge, publish,
18
- # distribute, sublicense, and/or sell copies of the Software, and to
19
- # permit persons to whom the Software is furnished to do so, subject to
20
- # the following conditions:
21
- #
22
- # The above copyright notice and this permission notice shall be
23
- # included in all copies or substantial portions of the Software.
24
- #
25
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
26
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
29
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
- #
33
- #---------------------------------------------------------------------------
34
- #
35
- #
36
-
37
- module ZMQMachine
38
-
39
- module Socket
40
-
41
- class XReq
42
- include ZMQMachine::Socket::Base
43
-
44
- def initialize context, handler
45
- @poll_options = ZMQ::POLLIN
46
- @kind = :xrequest
47
-
48
- super
49
- @state = :ready
50
- end
51
-
52
- # Attach a handler to the XREQ socket.
53
- #
54
- # A XREQ socket has no restrictions on the number of sends and
55
- # recieves. Each send will silently prepend a message part to
56
- # your outgoing data which the REP/XREP socket on the other end
57
- # will use for matching up the transaction.
58
- #
59
- # This socket expects its +handler+ to
60
- # implement at least the #on_readable method. This method
61
- # will be called whenever a reply arrives. The #on_writable method
62
- # will be called continually until the socket HWM is breached.
63
- #
64
- # For error handling purposes, the handler must also
65
- # implement #on_readable_error.
66
- #
67
- def on_attach handler
68
- raise ArgumentError, "Handler must implement an #on_readable method" unless handler.respond_to? :on_readable
69
- raise ArgumentError, "Handler must implement an #on_readable_error method" unless handler.respond_to? :on_readable_error
70
- raise ArgumentError, "Handler must implement an #on_readable method" unless handler.respond_to? :on_writable
71
- raise ArgumentError, "Handler must implement an #on_readable_error method" unless handler.respond_to? :on_writable_error
72
- super
73
- end
74
-
75
-
76
- private
77
-
78
- def allocate_socket context
79
- sock = ZMQ::Socket.new context.pointer, ZMQ::XREQ
80
- sock
81
- end
82
- end # class XReq
83
-
84
- end # module Socket
85
-
86
- end # module ZMQMachine