omq 0.8.0 → 0.10.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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +87 -0
  3. data/README.md +9 -49
  4. data/lib/omq/channel.rb +3 -3
  5. data/lib/omq/client_server.rb +6 -6
  6. data/lib/omq/engine.rb +641 -0
  7. data/lib/omq/options.rb +46 -0
  8. data/lib/omq/pair.rb +2 -2
  9. data/lib/omq/peer.rb +3 -3
  10. data/lib/omq/pub_sub.rb +6 -6
  11. data/lib/omq/push_pull.rb +2 -2
  12. data/lib/omq/radio_dish.rb +2 -2
  13. data/lib/omq/reactor.rb +128 -0
  14. data/lib/omq/readable.rb +42 -0
  15. data/lib/omq/req_rep.rb +4 -4
  16. data/lib/omq/router_dealer.rb +4 -4
  17. data/lib/omq/routing/channel.rb +83 -0
  18. data/lib/omq/routing/client.rb +56 -0
  19. data/lib/omq/routing/dealer.rb +57 -0
  20. data/lib/omq/routing/dish.rb +78 -0
  21. data/lib/omq/routing/fan_out.rb +131 -0
  22. data/lib/omq/routing/gather.rb +46 -0
  23. data/lib/omq/routing/pair.rb +86 -0
  24. data/lib/omq/routing/peer.rb +101 -0
  25. data/lib/omq/routing/pub.rb +60 -0
  26. data/lib/omq/routing/pull.rb +46 -0
  27. data/lib/omq/routing/push.rb +81 -0
  28. data/lib/omq/routing/radio.rb +140 -0
  29. data/lib/omq/routing/rep.rb +101 -0
  30. data/lib/omq/routing/req.rb +65 -0
  31. data/lib/omq/routing/round_robin.rb +168 -0
  32. data/lib/omq/routing/router.rb +110 -0
  33. data/lib/omq/routing/scatter.rb +82 -0
  34. data/lib/omq/routing/server.rb +101 -0
  35. data/lib/omq/routing/sub.rb +78 -0
  36. data/lib/omq/routing/xpub.rb +72 -0
  37. data/lib/omq/routing/xsub.rb +83 -0
  38. data/lib/omq/routing.rb +66 -0
  39. data/lib/omq/scatter_gather.rb +4 -4
  40. data/lib/omq/single_frame.rb +18 -0
  41. data/lib/omq/socket.rb +24 -9
  42. data/lib/omq/transport/inproc.rb +355 -0
  43. data/lib/omq/transport/ipc.rb +117 -0
  44. data/lib/omq/transport/tcp.rb +111 -0
  45. data/lib/omq/version.rb +1 -1
  46. data/lib/omq/writable.rb +65 -0
  47. data/lib/omq.rb +60 -4
  48. metadata +38 -58
  49. data/exe/omq +0 -6
  50. data/lib/omq/cli/base_runner.rb +0 -459
  51. data/lib/omq/cli/channel.rb +0 -8
  52. data/lib/omq/cli/client_server.rb +0 -111
  53. data/lib/omq/cli/config.rb +0 -54
  54. data/lib/omq/cli/formatter.rb +0 -75
  55. data/lib/omq/cli/pair.rb +0 -31
  56. data/lib/omq/cli/peer.rb +0 -8
  57. data/lib/omq/cli/pipe.rb +0 -265
  58. data/lib/omq/cli/pub_sub.rb +0 -14
  59. data/lib/omq/cli/push_pull.rb +0 -14
  60. data/lib/omq/cli/radio_dish.rb +0 -27
  61. data/lib/omq/cli/req_rep.rb +0 -83
  62. data/lib/omq/cli/router_dealer.rb +0 -76
  63. data/lib/omq/cli/scatter_gather.rb +0 -14
  64. data/lib/omq/cli.rb +0 -540
  65. data/lib/omq/zmtp/engine.rb +0 -551
  66. data/lib/omq/zmtp/options.rb +0 -48
  67. data/lib/omq/zmtp/reactor.rb +0 -131
  68. data/lib/omq/zmtp/readable.rb +0 -29
  69. data/lib/omq/zmtp/routing/channel.rb +0 -81
  70. data/lib/omq/zmtp/routing/client.rb +0 -56
  71. data/lib/omq/zmtp/routing/dealer.rb +0 -57
  72. data/lib/omq/zmtp/routing/dish.rb +0 -80
  73. data/lib/omq/zmtp/routing/fan_out.rb +0 -131
  74. data/lib/omq/zmtp/routing/gather.rb +0 -48
  75. data/lib/omq/zmtp/routing/pair.rb +0 -84
  76. data/lib/omq/zmtp/routing/peer.rb +0 -100
  77. data/lib/omq/zmtp/routing/pub.rb +0 -62
  78. data/lib/omq/zmtp/routing/pull.rb +0 -48
  79. data/lib/omq/zmtp/routing/push.rb +0 -80
  80. data/lib/omq/zmtp/routing/radio.rb +0 -139
  81. data/lib/omq/zmtp/routing/rep.rb +0 -101
  82. data/lib/omq/zmtp/routing/req.rb +0 -65
  83. data/lib/omq/zmtp/routing/round_robin.rb +0 -143
  84. data/lib/omq/zmtp/routing/router.rb +0 -109
  85. data/lib/omq/zmtp/routing/scatter.rb +0 -81
  86. data/lib/omq/zmtp/routing/server.rb +0 -100
  87. data/lib/omq/zmtp/routing/sub.rb +0 -80
  88. data/lib/omq/zmtp/routing/xpub.rb +0 -74
  89. data/lib/omq/zmtp/routing/xsub.rb +0 -86
  90. data/lib/omq/zmtp/routing.rb +0 -65
  91. data/lib/omq/zmtp/single_frame.rb +0 -20
  92. data/lib/omq/zmtp/transport/inproc.rb +0 -359
  93. data/lib/omq/zmtp/transport/ipc.rb +0 -118
  94. data/lib/omq/zmtp/transport/tcp.rb +0 -117
  95. data/lib/omq/zmtp/writable.rb +0 -61
  96. 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"