omq 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +129 -0
  3. data/README.md +28 -3
  4. data/lib/omq/channel.rb +5 -5
  5. data/lib/omq/client_server.rb +10 -10
  6. data/lib/omq/engine.rb +702 -0
  7. data/lib/omq/options.rb +48 -0
  8. data/lib/omq/pair.rb +4 -4
  9. data/lib/omq/peer.rb +5 -5
  10. data/lib/omq/pub_sub.rb +18 -18
  11. data/lib/omq/push_pull.rb +6 -6
  12. data/lib/omq/queue_interface.rb +73 -0
  13. data/lib/omq/radio_dish.rb +6 -6
  14. data/lib/omq/reactor.rb +128 -0
  15. data/lib/omq/readable.rb +44 -0
  16. data/lib/omq/req_rep.rb +8 -8
  17. data/lib/omq/router_dealer.rb +8 -8
  18. data/lib/omq/routing/channel.rb +83 -0
  19. data/lib/omq/routing/client.rb +56 -0
  20. data/lib/omq/routing/dealer.rb +57 -0
  21. data/lib/omq/routing/dish.rb +78 -0
  22. data/lib/omq/routing/fan_out.rb +140 -0
  23. data/lib/omq/routing/gather.rb +46 -0
  24. data/lib/omq/routing/pair.rb +86 -0
  25. data/lib/omq/routing/peer.rb +101 -0
  26. data/lib/omq/routing/pub.rb +60 -0
  27. data/lib/omq/routing/pull.rb +46 -0
  28. data/lib/omq/routing/push.rb +81 -0
  29. data/lib/omq/routing/radio.rb +150 -0
  30. data/lib/omq/routing/rep.rb +101 -0
  31. data/lib/omq/routing/req.rb +65 -0
  32. data/lib/omq/routing/round_robin.rb +168 -0
  33. data/lib/omq/routing/router.rb +110 -0
  34. data/lib/omq/routing/scatter.rb +82 -0
  35. data/lib/omq/routing/server.rb +101 -0
  36. data/lib/omq/routing/sub.rb +78 -0
  37. data/lib/omq/routing/xpub.rb +72 -0
  38. data/lib/omq/routing/xsub.rb +83 -0
  39. data/lib/omq/routing.rb +66 -0
  40. data/lib/omq/scatter_gather.rb +8 -8
  41. data/lib/omq/single_frame.rb +18 -0
  42. data/lib/omq/socket.rb +32 -11
  43. data/lib/omq/transport/inproc.rb +355 -0
  44. data/lib/omq/transport/ipc.rb +117 -0
  45. data/lib/omq/transport/tcp.rb +111 -0
  46. data/lib/omq/transport/tls.rb +146 -0
  47. data/lib/omq/version.rb +1 -1
  48. data/lib/omq/writable.rb +66 -0
  49. data/lib/omq.rb +64 -4
  50. metadata +34 -33
  51. data/lib/omq/zmtp/engine.rb +0 -551
  52. data/lib/omq/zmtp/options.rb +0 -48
  53. data/lib/omq/zmtp/reactor.rb +0 -131
  54. data/lib/omq/zmtp/readable.rb +0 -29
  55. data/lib/omq/zmtp/routing/channel.rb +0 -81
  56. data/lib/omq/zmtp/routing/client.rb +0 -56
  57. data/lib/omq/zmtp/routing/dealer.rb +0 -57
  58. data/lib/omq/zmtp/routing/dish.rb +0 -80
  59. data/lib/omq/zmtp/routing/fan_out.rb +0 -131
  60. data/lib/omq/zmtp/routing/gather.rb +0 -48
  61. data/lib/omq/zmtp/routing/pair.rb +0 -84
  62. data/lib/omq/zmtp/routing/peer.rb +0 -100
  63. data/lib/omq/zmtp/routing/pub.rb +0 -62
  64. data/lib/omq/zmtp/routing/pull.rb +0 -48
  65. data/lib/omq/zmtp/routing/push.rb +0 -80
  66. data/lib/omq/zmtp/routing/radio.rb +0 -139
  67. data/lib/omq/zmtp/routing/rep.rb +0 -101
  68. data/lib/omq/zmtp/routing/req.rb +0 -65
  69. data/lib/omq/zmtp/routing/round_robin.rb +0 -143
  70. data/lib/omq/zmtp/routing/router.rb +0 -109
  71. data/lib/omq/zmtp/routing/scatter.rb +0 -81
  72. data/lib/omq/zmtp/routing/server.rb +0 -100
  73. data/lib/omq/zmtp/routing/sub.rb +0 -80
  74. data/lib/omq/zmtp/routing/xpub.rb +0 -74
  75. data/lib/omq/zmtp/routing/xsub.rb +0 -86
  76. data/lib/omq/zmtp/routing.rb +0 -65
  77. data/lib/omq/zmtp/single_frame.rb +0 -20
  78. data/lib/omq/zmtp/transport/inproc.rb +0 -359
  79. data/lib/omq/zmtp/transport/ipc.rb +0 -118
  80. data/lib/omq/zmtp/transport/tcp.rb +0 -117
  81. data/lib/omq/zmtp/writable.rb +0 -61
  82. data/lib/omq/zmtp.rb +0 -81
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "timeout"
4
-
5
- module OMQ
6
- module ZMTP
7
- # Pure Ruby Writable mixin. Enqueues messages to the engine's send path.
8
- #
9
- module Writable
10
- # Sends a message.
11
- #
12
- # @param message [String, Array<String>] message parts
13
- # @return [self]
14
- # @raise [IO::TimeoutError] if write_timeout exceeded
15
- #
16
- def send(message)
17
- parts = freeze_message(message)
18
- with_timeout(@options.write_timeout) { @engine.enqueue_send(parts) }
19
- self
20
- end
21
-
22
- # Sends a message (chainable).
23
- #
24
- # @param message [String, Array<String>]
25
- # @return [self]
26
- #
27
- def <<(message)
28
- send(message)
29
- end
30
-
31
- private
32
-
33
- # Converts a message into a frozen array of frozen binary strings.
34
- #
35
- # @param message [String, Array<String>]
36
- # @return [Array<String>] frozen array of frozen binary strings
37
- #
38
- def freeze_message(message)
39
- parts = message.is_a?(Array) ? message : [message]
40
- raise ArgumentError, "message has no parts" if parts.empty?
41
- if parts.frozen?
42
- parts = parts.map { |p| p.to_str.b.freeze }
43
- else
44
- parts.map! { |p| p.to_str.b.freeze }
45
- end
46
- parts.freeze
47
- end
48
-
49
- public
50
-
51
- # Waits until the socket is writable.
52
- #
53
- # @param timeout [Numeric, nil] timeout in seconds
54
- # @return [true]
55
- #
56
- def wait_writable(timeout = @options.write_timeout)
57
- true
58
- end
59
- end
60
- end
61
- end
data/lib/omq/zmtp.rb DELETED
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "protocol/zmtp"
4
- require "io/stream"
5
-
6
- module OMQ
7
- # ZMTP 3.1 protocol internals.
8
- #
9
- # The wire protocol (codec, connection, mechanisms) lives in the
10
- # protocol-zmtp gem. This module re-exports those classes under the
11
- # OMQ::ZMTP namespace and adds the transport/routing/engine layers.
12
- #
13
- module ZMTP
14
- # Re-export protocol-zmtp classes
15
- Codec = Protocol::ZMTP::Codec
16
- Connection = Protocol::ZMTP::Connection
17
- ProtocolError = Protocol::ZMTP::Error
18
- VALID_PEERS = Protocol::ZMTP::VALID_PEERS
19
-
20
- module Mechanism
21
- Null = Protocol::ZMTP::Mechanism::Null
22
- Curve = Protocol::ZMTP::Mechanism::Curve if defined?(Protocol::ZMTP::Mechanism::Curve)
23
- end
24
-
25
- # Errors raised when a peer disconnects or resets the connection.
26
- CONNECTION_LOST = [
27
- EOFError,
28
- IOError,
29
- Errno::EPIPE,
30
- Errno::ECONNRESET,
31
- Errno::ECONNABORTED,
32
- Errno::ENOTCONN,
33
- IO::Stream::ConnectionResetError,
34
- ].freeze
35
-
36
- # Errors raised when a peer cannot be reached.
37
- CONNECTION_FAILED = [
38
- Errno::ECONNREFUSED,
39
- Errno::ENOENT,
40
- Errno::ETIMEDOUT,
41
- Errno::EHOSTUNREACH,
42
- Errno::ENETUNREACH,
43
- Socket::ResolutionError,
44
- ].freeze
45
- end
46
- end
47
-
48
- # Transport
49
- require_relative "zmtp/transport/inproc"
50
- require_relative "zmtp/transport/tcp"
51
- require_relative "zmtp/transport/ipc"
52
-
53
- # Core
54
- require_relative "zmtp/reactor"
55
- require_relative "zmtp/options"
56
- require_relative "zmtp/routing"
57
- require_relative "zmtp/routing/round_robin"
58
- require_relative "zmtp/routing/fan_out"
59
- require_relative "zmtp/routing/pair"
60
- require_relative "zmtp/routing/req"
61
- require_relative "zmtp/routing/rep"
62
- require_relative "zmtp/routing/dealer"
63
- require_relative "zmtp/routing/router"
64
- require_relative "zmtp/routing/pub"
65
- require_relative "zmtp/routing/sub"
66
- require_relative "zmtp/routing/xpub"
67
- require_relative "zmtp/routing/xsub"
68
- require_relative "zmtp/routing/push"
69
- require_relative "zmtp/routing/pull"
70
- require_relative "zmtp/routing/scatter"
71
- require_relative "zmtp/routing/gather"
72
- require_relative "zmtp/routing/channel"
73
- require_relative "zmtp/routing/client"
74
- require_relative "zmtp/routing/server"
75
- require_relative "zmtp/routing/radio"
76
- require_relative "zmtp/routing/dish"
77
- require_relative "zmtp/routing/peer"
78
- require_relative "zmtp/single_frame"
79
- require_relative "zmtp/engine"
80
- require_relative "zmtp/readable"
81
- require_relative "zmtp/writable"