polyphony 0.42 → 0.43

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e284cae2a5eb2332bc8671090412bbe0cf7d57dbc163d68ba387f4d9635a8adf
4
- data.tar.gz: 58eba5a2607df83c7471b1a6b72cc350aa468e9a562e3d1e8f7451eaae12d068
3
+ metadata.gz: 4eb88a97bf07f85f50aa46923883fce2fe1bbd253407021a6f5bb246e0fdcfdc
4
+ data.tar.gz: c707861eb93f709661aa90abb33519004df5ff5db16f2d3da00387b292234027
5
5
  SHA512:
6
- metadata.gz: 10b7bcf9240ea8f7355c75d025bd6c5e1bd00c86e7985f71440091cc149c629279b16eaf1c863d85de29e278739926b499625c77238db8eb803aa235395771a4
7
- data.tar.gz: 9001df441fdc058a3234bca05f6cca55d3a27edcf0b5b0d126a9c371d37bd0ffecc4d13d8f13c614d9b7182630f94d54481035f6d83fb044aebdf3238f83b03a
6
+ metadata.gz: b554716ed26188fec86606198cdca669253d921017748ef0d9231db9f01e08e046b62fc38c0c6c3595a42f1976771db8b42c352c0431cc73f4b1ed64f7edf3c9
7
+ data.tar.gz: 3ba74e7427fab47a65cd466e9bbe14e48176f737f6fd7fca21b3143d75d1dd9fa2ddef24b723d83f26f321949171359d946cfd4281b3b96c33bf43593199adce
@@ -1,3 +1,9 @@
1
+ ## 0.43 2020-07-05
2
+
3
+ * Add IO#read_loop
4
+ * Fix OpenSSL extension
5
+ * More work on docs
6
+
1
7
  ## 0.42 2020-07-03
2
8
 
3
9
  * Improve documentation
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polyphony (0.42)
4
+ polyphony (0.43)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/TODO.md CHANGED
@@ -1,11 +1,10 @@
1
- ## 0.42
1
+ ## 0.43
2
2
 
3
3
  - Reimplement ResourcePool, Channel, Mutex using LibevQueue
4
4
  -- Add `Fiber#schedule_with_priority` method, aliased by `Fiber#wakeup`
5
5
  - Implement agent interface is virtual function table
6
6
  - Implement proxy agent for plugging in a user-provided agent class
7
7
 
8
- ## 0.43
9
8
  - Debugging
10
9
  - Eat your own dogfood: need a good tool to check what's going on when some
11
10
  test fails
@@ -46,13 +46,13 @@ heading_anchors: true
46
46
  back_to_top: true
47
47
  back_to_top_text: "Back to top"
48
48
 
49
- footer_content: "Copyright &copy; 2018-2020 Sharon Rosner. Distributed by an <a href=\"https://github.com/digital-fabric/polyphony/tree/master/LICENSE.txt\">MIT license.</a>"
49
+ footer_content: "Copyright &copy; 2020 Sharon Rosner. Distributed by an <a href=\"https://github.com/digital-fabric/polyphony/tree/master/LICENSE\">MIT license.</a>"
50
50
 
51
51
  # Footer "Edit this page on GitHub" link text
52
52
  gh_edit_link: true # show or hide edit this page link
53
53
  gh_edit_link_text: "Edit this page on GitHub"
54
54
  gh_edit_repository: "https://github.com/digital-fabric/polyphony" # the github URL for your repo
55
- gh_edit_branch: "master" # the branch that your docs is served from
55
+ gh_edit_branch: "master/docs" # the branch that your docs is served from
56
56
  gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately
57
57
 
58
58
  compress_html:
@@ -416,28 +416,7 @@ request handler after all request headers have been received. This allows the
416
416
  application to better deal with slow client attacks, big file uploads, and also
417
417
  to minimize costly memory allocation and GC'ing.
418
418
 
419
- Preliminary benchmarks show the Polyphony web server to be about 3X as fast as
420
- Puma and 20X as fast as Unicorn. With SSL termination and using HTTP 2, the
421
- Polyphony web server is about 2X as fast as Falcon.
422
-
423
- ### HTTP/1
424
-
425
- |Server|requests/sec|average latency|max latency|
426
- |------|-----------:|--------------:|----------:|
427
- |Puma|
428
- |Unicorn|
429
- |Agoo|
430
- |Polyphony|
431
-
432
- ### HTTP/2 with SSL Termination
433
-
434
- |Server|requests/sec|average latency|max latency|
435
- |------|-----------:|--------------:|----------:|
436
- |Falcon|
437
- |Polyphony|
438
-
439
- (*Non-official benchmark with a basic "Hello world" Rack application. The usual
440
- caveats regarding benchmarks should be applied here.*)
419
+ Benchmarks will be included here at a later time.
441
420
 
442
421
  ## Integrating Polyphony with other Gems
443
422
 
@@ -13,7 +13,7 @@ def handle_client(socket)
13
13
  parser.on_message_complete = proc do |env|
14
14
  reqs << Object.new # parser
15
15
  end
16
- Thread.current.agent.read_loop(socket) do |data|
16
+ socket.read_loop do |data|
17
17
  parser << data
18
18
  while (req = reqs.shift)
19
19
  handle_request(socket, req)
@@ -201,6 +201,10 @@ class ::IO
201
201
  buf ? readpartial(maxlen, buf) : readpartial(maxlen)
202
202
  end
203
203
 
204
+ def read_loop(&block)
205
+ Thread.current.agent.read_loop(self, &block)
206
+ end
207
+
204
208
  # alias_method :orig_read, :read
205
209
  # def read(length = nil, outbuf = nil)
206
210
  # if length
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'openssl'
4
-
5
4
  require_relative './socket'
6
5
 
7
6
  # Open ssl socket helper methods (to make it compatible with Socket API)
@@ -18,12 +17,36 @@ class ::OpenSSL::SSL::SSLSocket
18
17
  io.reuse_addr
19
18
  end
20
19
 
21
- def sysread(maxlen, buf)
20
+ alias_method :orig_accept, :accept
21
+ def accept
22
+ loop do
23
+ result = accept_nonblock(exception: false)
24
+ case result
25
+ when :wait_readable then Thread.current.agent.wait_io(io, false)
26
+ when :wait_writable then Thread.current.agent.wait_io(io, true)
27
+ else
28
+ return result
29
+ end
30
+ end
31
+ end
32
+
33
+ alias_method :orig_sysread, :sysread
34
+ def sysread(maxlen, buf = +'')
22
35
  loop do
23
36
  case (result = read_nonblock(maxlen, buf, exception: false))
24
37
  when :wait_readable then Thread.current.agent.wait_io(io, false)
38
+ else return result
39
+ end
40
+ end
41
+ end
42
+
43
+ alias_method :orig_syswrite, :syswrite
44
+ def syswrite(buf)
45
+ loop do
46
+ case (result = write_nonblock(buf, exception: false))
25
47
  when :wait_writable then Thread.current.agent.wait_io(io, true)
26
- else result
48
+ else
49
+ return result
27
50
  end
28
51
  end
29
52
  end
@@ -37,13 +60,14 @@ class ::OpenSSL::SSL::SSLSocket
37
60
  # @sync = osync
38
61
  end
39
62
 
40
- def syswrite(buf)
41
- loop do
42
- case (result = write_nonblock(buf, exception: false))
43
- when :wait_readable then Thread.current.agent.wait_io(io, false)
44
- when :wait_writable then Thread.current.agent.wait_io(io, true)
45
- else result
46
- end
63
+ def readpartial(maxlen, buf = +'')
64
+ result = sysread(maxlen, buf)
65
+ result || (raise EOFError)
66
+ end
67
+
68
+ def read_loop
69
+ while (data = sysread(8192))
70
+ yield data
47
71
  end
48
72
  end
49
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polyphony
4
- VERSION = '0.42'
4
+ VERSION = '0.43'
5
5
  end
@@ -8,7 +8,8 @@ class SocketTest < MiniTest::Test
8
8
  end
9
9
 
10
10
  def test_tcp
11
- server = TCPServer.new('127.0.0.1', 1234)
11
+ port = rand(1234..5678)
12
+ server = TCPServer.new('127.0.0.1', port)
12
13
 
13
14
  server_fiber = spin do
14
15
  while (socket = server.accept)
@@ -21,13 +22,13 @@ class SocketTest < MiniTest::Test
21
22
  end
22
23
 
23
24
  snooze
24
- client = TCPSocket.new('127.0.0.1', 1234)
25
+ client = TCPSocket.new('127.0.0.1', port)
25
26
  client.write("1234\n")
26
27
  assert_equal "1234\n", client.readpartial(8192)
27
28
  client.close
28
29
  ensure
29
- server_fiber.stop
30
- snooze
30
+ server_fiber&.stop
31
+ server_fiber&.await
31
32
  server&.close
32
33
  end
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyphony
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.42'
4
+ version: '0.43'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty