omq 0.17.8 → 0.18.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.
@@ -18,7 +18,7 @@ module OMQ
18
18
  #
19
19
  def bind(endpoint, engine)
20
20
  host, port = self.parse_endpoint(endpoint)
21
- host = "0.0.0.0" if host == "*"
21
+ host = "0.0.0.0" if host == "*" # FIXME: support IPv6, see omq-cli v0.11.2
22
22
 
23
23
  addrs = Addrinfo.getaddrinfo(host, port, nil, :STREAM, nil, ::Socket::AI_PASSIVE)
24
24
  raise ::Socket::ResolutionError, "no addresses for #{host}" if addrs.empty?
@@ -85,9 +85,20 @@ module OMQ
85
85
  end
86
86
 
87
87
 
88
+ # Applies SO_SNDBUF / SO_RCVBUF to +sock+ from the socket's
89
+ # {Options}. No-op when both are nil (OS default).
90
+ #
91
+ # @param sock [Socket, TCPSocket]
92
+ # @param options [Options]
93
+ #
88
94
  def apply_buffer_sizes(sock, options)
89
- sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, options.sndbuf) if options.sndbuf
90
- sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF, options.rcvbuf) if options.rcvbuf
95
+ if options.sndbuf
96
+ sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, options.sndbuf)
97
+ end
98
+
99
+ if options.rcvbuf
100
+ sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF, options.rcvbuf)
101
+ end
91
102
  end
92
103
  end
93
104
 
@@ -130,11 +141,16 @@ module OMQ
130
141
  #
131
142
  def start_accept_loops(parent_task, &on_accepted)
132
143
  @tasks = @servers.map do |server|
133
- parent_task.async(transient: true, annotation: "tcp accept #{@endpoint}") do
144
+ # TODO: use this server's exact host:port (@endpoint might not be unique)
145
+ annotation = "tcp accept #{@endpoint}"
146
+ parent_task.async(transient: true, annotation:) do
134
147
  loop do
135
148
  client = server.accept
136
149
  TCP.apply_buffer_sizes(client, @engine.options)
137
- Async::Task.current.defer_stop { on_accepted.call(IO::Stream::Buffered.wrap(client)) }
150
+ Async::Task.current.defer_stop do
151
+ # TODO: why not yield?
152
+ on_accepted.call(IO::Stream::Buffered.wrap(client))
153
+ end
138
154
  end
139
155
  rescue Async::Stop
140
156
  rescue IOError
data/lib/omq/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OMQ
4
- VERSION = "0.17.8"
4
+ VERSION = "0.18.0"
5
5
  end
data/lib/omq/writable.rb CHANGED
@@ -15,7 +15,11 @@ module OMQ
15
15
  #
16
16
  def send(message)
17
17
  parts = freeze_message(message)
18
- Reactor.run { with_timeout(@options.write_timeout) { @engine.enqueue_send(parts) } }
18
+
19
+ Reactor.run timeout: @options.write_timeout do |task|
20
+ @engine.enqueue_send(parts)
21
+ end
22
+
19
23
  self
20
24
  end
21
25
 
data/lib/omq.rb CHANGED
@@ -38,6 +38,7 @@ module OMQ
38
38
  IO::Stream::ConnectionResetError,
39
39
  ]
40
40
 
41
+
41
42
  # Errors raised when a peer cannot be reached.
42
43
  CONNECTION_FAILED = [
43
44
  Errno::ECONNREFUSED,
@@ -57,7 +58,7 @@ module OMQ
57
58
  CONNECTION_LOST.freeze
58
59
  CONNECTION_FAILED.freeze
59
60
  Engine.transports.freeze
60
- Routing.instance_variable_get(:@registry).freeze
61
+ Routing.registry.freeze
61
62
  end
62
63
  end
63
64
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.8
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '0.4'
18
+ version: '0.6'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '0.4'
25
+ version: '0.6'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: async
28
28
  requirement: !ruby/object:Gem::Requirement