polyphony 0.15 → 0.16
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +11 -3
- data/TODO.md +25 -14
- data/docs/getting-started/getting-started.md +1 -1
- data/docs/getting-started/tutorial.md +2 -0
- data/examples/core/cancel.rb +2 -3
- data/examples/core/channel_echo.rb +2 -3
- data/examples/core/enumerator.rb +2 -3
- data/examples/core/fork.rb +2 -2
- data/examples/core/genserver.rb +2 -3
- data/examples/core/lock.rb +2 -3
- data/examples/core/move_on.rb +2 -3
- data/examples/core/move_on_twice.rb +2 -3
- data/examples/core/move_on_with_ensure.rb +2 -3
- data/examples/core/{multiple_async.rb → multiple_spawn.rb} +2 -3
- data/examples/core/nested_async.rb +2 -3
- data/examples/core/nested_cancel.rb +2 -3
- data/examples/core/{nested_multiple_async.rb → nested_multiple_spawn.rb} +2 -3
- data/examples/core/next_tick.rb +4 -5
- data/examples/core/pulse.rb +2 -3
- data/examples/core/resource.rb +2 -3
- data/examples/core/resource_cancel.rb +2 -3
- data/examples/core/resource_delegate.rb +2 -3
- data/examples/core/sleep.rb +2 -3
- data/examples/core/sleep_spawn.rb +19 -0
- data/examples/core/spawn.rb +2 -3
- data/examples/core/spawn_cancel.rb +2 -3
- data/examples/core/spawn_error.rb +2 -2
- data/examples/core/supervisor.rb +2 -3
- data/examples/core/supervisor_with_cancel_scope.rb +2 -3
- data/examples/core/supervisor_with_error.rb +2 -3
- data/examples/core/supervisor_with_manual_move_on.rb +2 -3
- data/examples/core/thread.rb +3 -6
- data/examples/core/thread_cancel.rb +2 -5
- data/examples/core/thread_pool.rb +3 -6
- data/examples/core/throttle.rb +2 -3
- data/examples/fs/read.rb +22 -19
- data/examples/http/happy_eyeballs.rb +2 -2
- data/examples/http/http_client.rb +5 -7
- data/examples/http/http_server.rb +2 -3
- data/examples/http/http_server_forked.rb +2 -3
- data/examples/http/http_server_throttled.rb +2 -3
- data/examples/http/http_ws_server.rb +4 -4
- data/examples/http/https_raw_client.rb +4 -5
- data/examples/http/https_server.rb +2 -3
- data/examples/http/https_wss_server.rb +2 -3
- data/examples/http/rack_server.rb +2 -4
- data/examples/http/rack_server_https.rb +2 -3
- data/examples/http/rack_server_https_forked.rb +2 -3
- data/examples/http/websocket_secure_server.rb +2 -3
- data/examples/http/websocket_server.rb +2 -3
- data/examples/interfaces/pg_client.rb +2 -4
- data/examples/interfaces/pg_pool.rb +4 -6
- data/examples/interfaces/{pg_query.rb → pg_transaction.rb} +2 -4
- data/examples/interfaces/redis_channels.rb +2 -4
- data/examples/interfaces/redis_client.rb +2 -4
- data/examples/interfaces/redis_pubsub.rb +2 -4
- data/examples/interfaces/redis_pubsub_perf.rb +2 -4
- data/examples/io/echo_client.rb +4 -5
- data/examples/io/echo_server.rb +2 -2
- data/examples/io/echo_server_with_timeout.rb +3 -5
- data/examples/io/echo_stdin.rb +3 -4
- data/examples/performance/perf_multi_snooze.rb +2 -2
- data/examples/performance/perf_snooze.rb +2 -2
- data/examples/performance/thread-vs-fiber/polyphony_server.rb +4 -5
- data/ext/ev/ev_module.c +3 -2
- data/lib/polyphony/{resource_pool.rb → core/resource_pool.rb} +0 -0
- data/lib/polyphony/core/supervisor.rb +8 -8
- data/lib/polyphony/extensions/{ssl.rb → openssl.rb} +0 -0
- data/lib/polyphony/http/agent.rb +1 -1
- data/lib/polyphony/http.rb +12 -4
- data/lib/polyphony/net.rb +8 -11
- data/lib/polyphony/{extensions/postgres.rb → postgres.rb} +1 -4
- data/lib/polyphony/{extensions/redis.rb → redis.rb} +3 -6
- data/lib/polyphony/version.rb +1 -1
- data/lib/polyphony/websocket.rb +1 -1
- data/lib/polyphony.rb +57 -21
- data/polyphony.gemspec +5 -4
- data/test/test_coprocess.rb +88 -15
- data/test/test_core.rb +142 -232
- data/test/test_ev.rb +88 -95
- data/test/test_io.rb +35 -41
- metadata +68 -16
- data/examples/core/sleep2.rb +0 -13
- data/examples/streams/lines.rb +0 -27
- data/examples/streams/stdio.rb +0 -18
- data/lib/polyphony/core.rb +0 -45
- data/lib/polyphony/server_task.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62006f0bdd66c2776a252724cf1f842c859a39d8bc150f8f3db839105bfc60b0
|
4
|
+
data.tar.gz: e662adc4addce7d90c5dfd17a635618e6d8164cad911670f60901bac309c767a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 402eaf9528351b93e8026a7c91492ea367c8279bee389834d9a5b2f4855c10d82f9f1d23749cce1e1f5b38ac7f136001f0ffe6570051261d19e7e25fa6ca5f65
|
7
|
+
data.tar.gz: ed423faa2cfcf852277fc724e232e3836e8bdb0fcd98e009166fee7b8088f6d5db18aea1fa9e97c1fcc519e01c666d6a15fbaa9c87c337559bab04cc7f6957b3
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,31 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
polyphony (0.
|
4
|
+
polyphony (0.16)
|
5
5
|
http-2 (= 0.10.0)
|
6
6
|
http_parser.rb (= 0.6.0)
|
7
|
-
modulation (= 0.
|
7
|
+
modulation (= 0.24)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
+
hiredis (0.6.3)
|
12
13
|
http-2 (0.10.0)
|
13
14
|
http_parser.rb (0.6.0)
|
14
15
|
localhost (1.1.4)
|
15
16
|
minitest (5.11.3)
|
16
|
-
modulation (0.
|
17
|
+
modulation (0.24)
|
18
|
+
pg (1.1.3)
|
17
19
|
rake (12.3.2)
|
18
20
|
rake-compiler (1.0.5)
|
19
21
|
rake
|
22
|
+
redis (4.1.0)
|
23
|
+
websocket (1.2.8)
|
20
24
|
|
21
25
|
PLATFORMS
|
22
26
|
ruby
|
23
27
|
|
24
28
|
DEPENDENCIES
|
29
|
+
hiredis (= 0.6.3)
|
25
30
|
localhost (= 1.1.4)
|
26
31
|
minitest (= 5.11.3)
|
32
|
+
pg (= 1.1.3)
|
27
33
|
polyphony!
|
28
34
|
rake-compiler (= 1.0.5)
|
35
|
+
redis (= 4.1.0)
|
36
|
+
websocket (= 1.2.8)
|
29
37
|
|
30
38
|
BUNDLED WITH
|
31
39
|
1.17.2
|
data/TODO.md
CHANGED
@@ -1,24 +1,35 @@
|
|
1
|
-
|
1
|
+
# Roadmap:
|
2
2
|
|
3
|
-
|
3
|
+
## 0.17 Full or almost full functionality of `IO` using monkey patching
|
4
4
|
|
5
|
+
- testing - check conformance to Ruby `IO` API (as described in the Ruby docs)
|
6
|
+
- implement as much as possible in C
|
5
7
|
|
6
|
-
##
|
8
|
+
## 0.18 Working net/http, httparty
|
7
9
|
|
8
|
-
-
|
9
|
-
- test
|
10
|
-
- test
|
10
|
+
- implement `TCPSocket`/`TCPServer` functionality
|
11
|
+
- test `socket` classes
|
12
|
+
- test `Net::HTTP`
|
13
|
+
- test `httparty`
|
11
14
|
|
12
|
-
##
|
15
|
+
## 0.19 Full Rack adapter implementation
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
- follow Rack specification (doesn't have to include stuff like streaming or
|
18
|
+
websockets)
|
19
|
+
- find some demo Rack apps and test with Polyphony
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
## 0.20 Working Rails application
|
22
|
+
|
23
|
+
- benchmarks!
|
24
|
+
|
25
|
+
## 0.21 Testing
|
26
|
+
|
27
|
+
- test thread / thread_pool modules
|
28
|
+
- report test coverage
|
29
|
+
|
30
|
+
## 0.22 Documentation
|
31
|
+
|
32
|
+
# DNS
|
22
33
|
|
23
34
|
## DNS client
|
24
35
|
|
data/examples/core/cancel.rb
CHANGED
data/examples/core/enumerator.rb
CHANGED
data/examples/core/fork.rb
CHANGED
data/examples/core/genserver.rb
CHANGED
data/examples/core/lock.rb
CHANGED
data/examples/core/move_on.rb
CHANGED
data/examples/core/next_tick.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'polyphony'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
EV.next_tick do
|
6
|
+
next_tick do
|
8
7
|
puts "two"
|
9
|
-
|
8
|
+
next_tick { puts "four" }
|
10
9
|
puts "three"
|
11
10
|
end
|
12
11
|
|
data/examples/core/pulse.rb
CHANGED
data/examples/core/resource.rb
CHANGED
data/examples/core/sleep.rb
CHANGED
data/examples/core/spawn.rb
CHANGED
data/examples/core/supervisor.rb
CHANGED
data/examples/core/thread.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require 'socket'
|
6
|
-
|
7
|
-
Polyphony = import('../../lib/polyphony')
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'polyphony'
|
8
5
|
|
9
6
|
def lengthy_op
|
10
7
|
IO.read('../../docs/reality-ui.bmpr')
|
11
8
|
end
|
12
9
|
|
13
|
-
X =
|
10
|
+
X = 1000
|
14
11
|
|
15
12
|
def blocking
|
16
13
|
t0 = Time.now
|
@@ -1,13 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require 'socket'
|
6
|
-
|
7
|
-
Polyphony = import('../../lib/polyphony')
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'polyphony'
|
8
5
|
|
9
6
|
def lengthy_op
|
10
|
-
data = IO.read('../../docs/
|
7
|
+
data = IO.read('../../docs/dev-journal.md')
|
11
8
|
data.clear
|
12
9
|
# Socket.getaddrinfo('debian.org', 80)
|
13
10
|
#Digest::SHA256.digest(IO.read('doc/Promise.html'))
|
data/examples/core/throttle.rb
CHANGED
data/examples/fs/read.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'polyphony'
|
5
|
+
require 'polyphony/fs'
|
6
6
|
|
7
7
|
PATH = File.expand_path('../../../../docs/dev-journal.md', __dir__)
|
8
8
|
|
@@ -12,26 +12,29 @@ def raw_read_file(x)
|
|
12
12
|
puts "raw_read_file: #{Time.now - t0}"
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
x.times { nexus << async { read_file } }
|
15
|
+
def threaded_read_file(x, y)
|
16
|
+
t0 = Time.now
|
17
|
+
threads = []
|
18
|
+
y.times {
|
19
|
+
threads << Thread.new { x.times { IO.orig_read(PATH) } }
|
20
|
+
}
|
21
|
+
threads.each(&:join)
|
22
|
+
puts "threaded_read_file: #{Time.now - t0}"
|
24
23
|
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
spawn do
|
25
|
+
def thread_pool_read_file(x, y)
|
29
26
|
t0 = Time.now
|
30
27
|
supervise do |s|
|
31
|
-
|
28
|
+
y.times {
|
29
|
+
s.spawn { x.times { IO.read(PATH) } }
|
30
|
+
}
|
32
31
|
end
|
33
32
|
puts "thread_pool_read_file: #{Time.now - t0}"
|
34
|
-
rescue Exception => e
|
35
|
-
p e
|
36
|
-
puts e.backtrace.join("\n")
|
37
33
|
end
|
34
|
+
|
35
|
+
Y = ARGV[0] ? ARGV[0].to_i : 10
|
36
|
+
X = ARGV[1] ? ARGV[1].to_i : 100
|
37
|
+
|
38
|
+
raw_read_file(X * Y)
|
39
|
+
threaded_read_file(X, Y)
|
40
|
+
thread_pool_read_file(X, Y)
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# idea taken from the example given in trio:
|
4
4
|
# https://www.youtube.com/watch?v=oLkfnc_UMcE
|
5
5
|
|
6
|
-
require '
|
7
|
-
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'polyphony/http'
|
8
8
|
|
9
9
|
async def try_connect(target, supervisor)
|
10
10
|
puts "trying #{target[2]}"
|
@@ -1,19 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
Polyphony = import('../../lib/polyphony')
|
6
|
-
Agent = import('../../lib/polyphony/http/agent')
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'polyphony/http'
|
7
5
|
|
8
6
|
def get_server_time
|
9
|
-
Agent.get('https://ui.realiteq.net/', q: :time).json
|
7
|
+
Polyphony::HTTP::Agent.get('https://ui.realiteq.net/', q: :time).json
|
10
8
|
end
|
11
9
|
|
12
|
-
X =
|
10
|
+
X = 10
|
13
11
|
puts "Making #{X} requests..."
|
14
12
|
t0 = Time.now
|
15
13
|
supervise do |s|
|
16
|
-
X.times { get_server_time }
|
14
|
+
X.times { s.spawn { get_server_time } }
|
17
15
|
end
|
18
16
|
elapsed = Time.now - t0
|
19
17
|
puts "count: #{X} elapsed: #{elapsed} rate: #{X / elapsed} reqs/s"
|