ione 1.2.2 → 1.2.5
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.
- checksums.yaml +5 -5
- data/lib/ione/byte_buffer.rb +11 -3
- data/lib/ione/future.rb +67 -51
- data/lib/ione/io/acceptor.rb +1 -0
- data/lib/ione/io/base_connection.rb +2 -0
- data/lib/ione/io/connection.rb +1 -0
- data/lib/ione/io/io_reactor.rb +8 -7
- data/lib/ione/io/ssl_connection.rb +1 -0
- data/lib/ione/version.rb +1 -1
- data/spec/integration/io_spec.rb +3 -3
- data/spec/integration/ssl_spec.rb +7 -2
- data/spec/ione/byte_buffer_spec.rb +51 -37
- data/spec/ione/future_spec.rb +76 -65
- data/spec/ione/heap_spec.rb +18 -18
- data/spec/ione/io/acceptor_spec.rb +5 -5
- data/spec/ione/io/connection_common.rb +2 -2
- data/spec/ione/io/io_reactor_spec.rb +34 -18
- data/spec/ione/io/ssl_acceptor_spec.rb +3 -3
- data/spec/ione/io/ssl_connection_spec.rb +3 -3
- data/spec/spec_helper.rb +4 -0
- data/spec/support/fake_server.rb +1 -0
- metadata +14 -16
@@ -85,7 +85,7 @@ module Ione
|
|
85
85
|
stopped_future.value
|
86
86
|
restarted_future.value
|
87
87
|
begin
|
88
|
-
sequence.should
|
88
|
+
sequence.should eq([:stopped, :restarted])
|
89
89
|
ensure
|
90
90
|
reactor.stop
|
91
91
|
barrier.push(nil) while reactor.running?
|
@@ -93,6 +93,7 @@ module Ione
|
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'restarts the reactor even when restarted before a failed stop' do
|
96
|
+
pending 'This test is broken in JRuby' if RUBY_ENGINE == 'jruby'
|
96
97
|
barrier = Queue.new
|
97
98
|
selector.handler do
|
98
99
|
if barrier.pop == :fail
|
@@ -135,8 +136,6 @@ module Ione
|
|
135
136
|
|
136
137
|
context 'when already started' do
|
137
138
|
it 'is not started again' do
|
138
|
-
calls = 0
|
139
|
-
lock = Mutex.new
|
140
139
|
ticks = Queue.new
|
141
140
|
barrier = Queue.new
|
142
141
|
selector.handler do
|
@@ -171,12 +170,27 @@ module Ione
|
|
171
170
|
reactor.stop.value.should equal(reactor)
|
172
171
|
end
|
173
172
|
|
174
|
-
it 'is not running after
|
173
|
+
it 'is not running after stop completed' do
|
175
174
|
reactor.start.value
|
176
175
|
reactor.stop.value
|
177
176
|
reactor.should_not be_running
|
178
177
|
end
|
179
178
|
|
179
|
+
it 'keeps running until stop completed' do
|
180
|
+
running_barrier = Queue.new
|
181
|
+
stop_barrier = Queue.new
|
182
|
+
selector.handler do
|
183
|
+
running_barrier.push(nil)
|
184
|
+
stop_barrier.pop
|
185
|
+
[[], [], []]
|
186
|
+
end
|
187
|
+
reactor.start.value
|
188
|
+
future = reactor.stop
|
189
|
+
running_barrier.pop
|
190
|
+
reactor.should be_running
|
191
|
+
stop_barrier.push(nil) until future.completed?
|
192
|
+
end
|
193
|
+
|
180
194
|
it 'closes all sockets' do
|
181
195
|
reactor.start.value
|
182
196
|
connection = reactor.connect('example.com', 9999, 5).value
|
@@ -223,7 +237,7 @@ module Ione
|
|
223
237
|
reactor.on_error { |e| error = e }
|
224
238
|
reactor.start
|
225
239
|
await { error }
|
226
|
-
error.message.should
|
240
|
+
error.message.should eq('Blurgh')
|
227
241
|
end
|
228
242
|
|
229
243
|
it 'calls the listener immediately when the reactor has already crashed' do
|
@@ -253,16 +267,16 @@ module Ione
|
|
253
267
|
barrier.push(nil)
|
254
268
|
await { !reactor.running? }
|
255
269
|
reactor.on_error { calls << :pre_restarted }
|
256
|
-
calls.should
|
270
|
+
calls.should eq([
|
257
271
|
:pre_started,
|
258
272
|
:post_started,
|
259
273
|
:pre_restarted,
|
260
|
-
]
|
274
|
+
])
|
261
275
|
reactor.start
|
262
276
|
reactor.on_error { calls << :post_restarted }
|
263
277
|
barrier.push(nil)
|
264
278
|
await { !reactor.running? }
|
265
|
-
calls.should
|
279
|
+
calls.should eq([
|
266
280
|
:pre_started,
|
267
281
|
:post_started,
|
268
282
|
:pre_restarted,
|
@@ -270,7 +284,7 @@ module Ione
|
|
270
284
|
:post_started,
|
271
285
|
:pre_restarted,
|
272
286
|
:post_restarted,
|
273
|
-
]
|
287
|
+
])
|
274
288
|
end
|
275
289
|
end
|
276
290
|
|
@@ -287,19 +301,19 @@ module Ione
|
|
287
301
|
it 'returns a future that resolves to what the given block returns' do
|
288
302
|
reactor.start.value
|
289
303
|
x = reactor.connect('example.com', 9999, 5) { :foo }.value
|
290
|
-
x.should
|
304
|
+
x.should eq(:foo)
|
291
305
|
end
|
292
306
|
|
293
307
|
it 'defaults to 5 as the connection timeout' do
|
294
308
|
reactor.start.value
|
295
309
|
connection = reactor.connect('example.com', 9999).value
|
296
|
-
connection.connection_timeout.should
|
310
|
+
connection.connection_timeout.should eq(5)
|
297
311
|
end
|
298
312
|
|
299
313
|
it 'takes the connection timeout from the :timeout option' do
|
300
314
|
reactor.start.value
|
301
315
|
connection = reactor.connect('example.com', 9999, timeout: 9).value
|
302
|
-
connection.connection_timeout.should
|
316
|
+
connection.connection_timeout.should eq(9)
|
303
317
|
end
|
304
318
|
|
305
319
|
it 'returns the connection when no block is given' do
|
@@ -363,19 +377,19 @@ module Ione
|
|
363
377
|
it 'returns a future that resolves to what the given block returns' do
|
364
378
|
reactor.start.value
|
365
379
|
x = reactor.bind(ENV['SERVER_HOST'], port, 5) { |acceptor| :foo }.value
|
366
|
-
x.should
|
380
|
+
x.should eq(:foo)
|
367
381
|
end
|
368
382
|
|
369
383
|
it 'defaults to a backlog of 5' do
|
370
384
|
reactor.start.value
|
371
385
|
acceptor = reactor.bind(ENV['SERVER_HOST'], port).value
|
372
|
-
acceptor.backlog.should
|
386
|
+
acceptor.backlog.should eq(5)
|
373
387
|
end
|
374
388
|
|
375
389
|
it 'takes the backlog from the :backlog option' do
|
376
390
|
reactor.start.value
|
377
391
|
acceptor = reactor.bind(ENV['SERVER_HOST'], port, backlog: 9).value
|
378
|
-
acceptor.backlog.should
|
392
|
+
acceptor.backlog.should eq(9)
|
379
393
|
end
|
380
394
|
|
381
395
|
it 'returns the acceptor when no block is given' do
|
@@ -428,10 +442,12 @@ module Ione
|
|
428
442
|
end
|
429
443
|
|
430
444
|
it 'returns a future that is resolved after the specified duration' do
|
445
|
+
start = Time.now
|
431
446
|
clock.stub(:now).and_return(1)
|
432
|
-
f = reactor.schedule_timer(
|
433
|
-
clock.stub(:now).and_return(
|
447
|
+
f = reactor.schedule_timer(8)
|
448
|
+
clock.stub(:now).and_return(10.1)
|
434
449
|
await { f.resolved? }
|
450
|
+
expect(Time.now - start).to be < 1
|
435
451
|
end
|
436
452
|
end
|
437
453
|
|
@@ -744,4 +760,4 @@ module IoReactorSpec
|
|
744
760
|
@body.call(*args)
|
745
761
|
end
|
746
762
|
end
|
747
|
-
end
|
763
|
+
end
|
@@ -7,7 +7,7 @@ module Ione
|
|
7
7
|
module Io
|
8
8
|
describe SslAcceptor do
|
9
9
|
let :acceptor do
|
10
|
-
described_class.new('example.com', 4321,
|
10
|
+
described_class.new('example.com', 4321, 3, unblocker, reactor, ssl_context, socket_impl, ssl_socket_impl)
|
11
11
|
end
|
12
12
|
|
13
13
|
let :unblocker do
|
@@ -80,8 +80,8 @@ module Ione
|
|
80
80
|
acceptor.bind
|
81
81
|
acceptor.read
|
82
82
|
accepted_handlers.should have(1).item
|
83
|
-
accepted_handlers.first.host.should
|
84
|
-
accepted_handlers.first.port.should
|
83
|
+
accepted_handlers.first.host.should eq('example.com')
|
84
|
+
accepted_handlers.first.port.should eq(3333)
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'returns the raw socket from #to_io' do
|
@@ -124,7 +124,7 @@ module Ione
|
|
124
124
|
end
|
125
125
|
handler.connect
|
126
126
|
handler.read
|
127
|
-
read_sizes.drop(1).should
|
127
|
+
read_sizes.drop(1).should eq([read_sizes.first] * 3)
|
128
128
|
end
|
129
129
|
else
|
130
130
|
it 'reads and initial chunk of data' do
|
@@ -134,7 +134,7 @@ module Ione
|
|
134
134
|
ssl_socket.stub(:read_nonblock).and_return('fooo')
|
135
135
|
handler.connect
|
136
136
|
handler.read
|
137
|
-
data.should
|
137
|
+
data.should eq(['fooo'])
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'reads once, and then again with the value of #pending, until #pending returns zero' do
|
@@ -149,7 +149,7 @@ module Ione
|
|
149
149
|
end
|
150
150
|
handler.connect
|
151
151
|
handler.read
|
152
|
-
read_sizes.drop(1).should
|
152
|
+
read_sizes.drop(1).should eq([3, 2, 1])
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/fake_server.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ione
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo Hultberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Reactive programming framework for Ruby, painless evented IO, futures
|
14
14
|
and an efficient byte buffer
|
@@ -69,26 +69,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
|
73
|
-
rubygems_version: 2.2.2
|
72
|
+
rubygems_version: 3.0.3
|
74
73
|
signing_key:
|
75
74
|
specification_version: 4
|
76
75
|
summary: Reactive programming framework for Ruby
|
77
76
|
test_files:
|
78
|
-
- spec/
|
79
|
-
- spec/
|
80
|
-
- spec/ione/
|
81
|
-
- spec/ione/
|
82
|
-
- spec/ione/heap_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
- spec/ione/io/ssl_acceptor_spec.rb
|
79
|
+
- spec/ione/io/server_connection_spec.rb
|
80
|
+
- spec/ione/io/ssl_server_connection_spec.rb
|
83
81
|
- spec/ione/io/acceptor_spec.rb
|
84
|
-
- spec/ione/io/connection_common.rb
|
85
82
|
- spec/ione/io/connection_spec.rb
|
86
|
-
- spec/ione/io/io_reactor_spec.rb
|
87
|
-
- spec/ione/io/server_connection_spec.rb
|
88
|
-
- spec/ione/io/ssl_acceptor_spec.rb
|
89
83
|
- spec/ione/io/ssl_connection_spec.rb
|
90
|
-
- spec/ione/io/
|
91
|
-
- spec/
|
84
|
+
- spec/ione/io/io_reactor_spec.rb
|
85
|
+
- spec/ione/io/connection_common.rb
|
86
|
+
- spec/ione/heap_spec.rb
|
87
|
+
- spec/ione/byte_buffer_spec.rb
|
88
|
+
- spec/ione/future_spec.rb
|
89
|
+
- spec/integration/ssl_spec.rb
|
90
|
+
- spec/integration/io_spec.rb
|
92
91
|
- spec/support/await_helper.rb
|
93
92
|
- spec/support/fake_server.rb
|
94
|
-
has_rdoc:
|