polyphony 0.15 → 0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +11 -3
  4. data/TODO.md +25 -14
  5. data/docs/getting-started/getting-started.md +1 -1
  6. data/docs/getting-started/tutorial.md +2 -0
  7. data/examples/core/cancel.rb +2 -3
  8. data/examples/core/channel_echo.rb +2 -3
  9. data/examples/core/enumerator.rb +2 -3
  10. data/examples/core/fork.rb +2 -2
  11. data/examples/core/genserver.rb +2 -3
  12. data/examples/core/lock.rb +2 -3
  13. data/examples/core/move_on.rb +2 -3
  14. data/examples/core/move_on_twice.rb +2 -3
  15. data/examples/core/move_on_with_ensure.rb +2 -3
  16. data/examples/core/{multiple_async.rb → multiple_spawn.rb} +2 -3
  17. data/examples/core/nested_async.rb +2 -3
  18. data/examples/core/nested_cancel.rb +2 -3
  19. data/examples/core/{nested_multiple_async.rb → nested_multiple_spawn.rb} +2 -3
  20. data/examples/core/next_tick.rb +4 -5
  21. data/examples/core/pulse.rb +2 -3
  22. data/examples/core/resource.rb +2 -3
  23. data/examples/core/resource_cancel.rb +2 -3
  24. data/examples/core/resource_delegate.rb +2 -3
  25. data/examples/core/sleep.rb +2 -3
  26. data/examples/core/sleep_spawn.rb +19 -0
  27. data/examples/core/spawn.rb +2 -3
  28. data/examples/core/spawn_cancel.rb +2 -3
  29. data/examples/core/spawn_error.rb +2 -2
  30. data/examples/core/supervisor.rb +2 -3
  31. data/examples/core/supervisor_with_cancel_scope.rb +2 -3
  32. data/examples/core/supervisor_with_error.rb +2 -3
  33. data/examples/core/supervisor_with_manual_move_on.rb +2 -3
  34. data/examples/core/thread.rb +3 -6
  35. data/examples/core/thread_cancel.rb +2 -5
  36. data/examples/core/thread_pool.rb +3 -6
  37. data/examples/core/throttle.rb +2 -3
  38. data/examples/fs/read.rb +22 -19
  39. data/examples/http/happy_eyeballs.rb +2 -2
  40. data/examples/http/http_client.rb +5 -7
  41. data/examples/http/http_server.rb +2 -3
  42. data/examples/http/http_server_forked.rb +2 -3
  43. data/examples/http/http_server_throttled.rb +2 -3
  44. data/examples/http/http_ws_server.rb +4 -4
  45. data/examples/http/https_raw_client.rb +4 -5
  46. data/examples/http/https_server.rb +2 -3
  47. data/examples/http/https_wss_server.rb +2 -3
  48. data/examples/http/rack_server.rb +2 -4
  49. data/examples/http/rack_server_https.rb +2 -3
  50. data/examples/http/rack_server_https_forked.rb +2 -3
  51. data/examples/http/websocket_secure_server.rb +2 -3
  52. data/examples/http/websocket_server.rb +2 -3
  53. data/examples/interfaces/pg_client.rb +2 -4
  54. data/examples/interfaces/pg_pool.rb +4 -6
  55. data/examples/interfaces/{pg_query.rb → pg_transaction.rb} +2 -4
  56. data/examples/interfaces/redis_channels.rb +2 -4
  57. data/examples/interfaces/redis_client.rb +2 -4
  58. data/examples/interfaces/redis_pubsub.rb +2 -4
  59. data/examples/interfaces/redis_pubsub_perf.rb +2 -4
  60. data/examples/io/echo_client.rb +4 -5
  61. data/examples/io/echo_server.rb +2 -2
  62. data/examples/io/echo_server_with_timeout.rb +3 -5
  63. data/examples/io/echo_stdin.rb +3 -4
  64. data/examples/performance/perf_multi_snooze.rb +2 -2
  65. data/examples/performance/perf_snooze.rb +2 -2
  66. data/examples/performance/thread-vs-fiber/polyphony_server.rb +4 -5
  67. data/ext/ev/ev_module.c +3 -2
  68. data/lib/polyphony/{resource_pool.rb → core/resource_pool.rb} +0 -0
  69. data/lib/polyphony/core/supervisor.rb +8 -8
  70. data/lib/polyphony/extensions/{ssl.rb → openssl.rb} +0 -0
  71. data/lib/polyphony/http/agent.rb +1 -1
  72. data/lib/polyphony/http.rb +12 -4
  73. data/lib/polyphony/net.rb +8 -11
  74. data/lib/polyphony/{extensions/postgres.rb → postgres.rb} +1 -4
  75. data/lib/polyphony/{extensions/redis.rb → redis.rb} +3 -6
  76. data/lib/polyphony/version.rb +1 -1
  77. data/lib/polyphony/websocket.rb +1 -1
  78. data/lib/polyphony.rb +57 -21
  79. data/polyphony.gemspec +5 -4
  80. data/test/test_coprocess.rb +88 -15
  81. data/test/test_core.rb +142 -232
  82. data/test/test_ev.rb +88 -95
  83. data/test/test_io.rb +35 -41
  84. metadata +68 -16
  85. data/examples/core/sleep2.rb +0 -13
  86. data/examples/streams/lines.rb +0 -27
  87. data/examples/streams/stdio.rb +0 -18
  88. data/lib/polyphony/core.rb +0 -45
  89. data/lib/polyphony/server_task.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b20863a05d3f48a1b2af107ebeecb67c08cdeb20a7973cdcf6cf0e7ad3d31f7
4
- data.tar.gz: 62753e931ed71137ef4cc3c2b1b011f69cfaf2e578da65c6b193b3c40dc88e5f
3
+ metadata.gz: 62006f0bdd66c2776a252724cf1f842c859a39d8bc150f8f3db839105bfc60b0
4
+ data.tar.gz: e662adc4addce7d90c5dfd17a635618e6d8164cad911670f60901bac309c767a
5
5
  SHA512:
6
- metadata.gz: 075bbc81be5b7818f550186d6d5d4094e53245cd425743fff407b15573bcd7b4a7c9219d9628167589b13ea538c6202e72b5f782675135d397a6346323133391
7
- data.tar.gz: d4c25633ff9f79a14ae978fbf3c8a2e51ce1b7a7c82d5ab4aa007dae26780d7b29deca39bf285c885f197b67f290f78c91bccf0faaeb22b13a0481cc664d5a57
6
+ metadata.gz: 402eaf9528351b93e8026a7c91492ea367c8279bee389834d9a5b2f4855c10d82f9f1d23749cce1e1f5b38ac7f136001f0ffe6570051261d19e7e25fa6ca5f65
7
+ data.tar.gz: ed423faa2cfcf852277fc724e232e3836e8bdb0fcd98e009166fee7b8088f6d5db18aea1fa9e97c1fcc519e01c666d6a15fbaa9c87c337559bab04cc7f6957b3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.16 2019-05-22
2
+ ---------------
3
+
4
+ * Reorganize and refactor code
5
+ * Allow opening secure socket without OpenSSL context
6
+
1
7
  0.15 2019-05-20
2
8
  ---------------
3
9
 
data/Gemfile.lock CHANGED
@@ -1,31 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polyphony (0.15)
4
+ polyphony (0.16)
5
5
  http-2 (= 0.10.0)
6
6
  http_parser.rb (= 0.6.0)
7
- modulation (= 0.23)
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.23)
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
- ## Full or almost full functionality of IO using monkey patching
1
+ # Roadmap:
2
2
 
3
- - stuff like gets, getc etc should be using the ev reactor
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
- ## Testing
8
+ ## 0.18 Working net/http, httparty
7
9
 
8
- - test IO
9
- - test TCP server / client
10
- - test thread / thread_pool modules
10
+ - implement `TCPSocket`/`TCPServer` functionality
11
+ - test `socket` classes
12
+ - test `Net::HTTP`
13
+ - test `httparty`
11
14
 
12
- ## UDP socket
15
+ ## 0.19 Full Rack adapter implementation
13
16
 
14
- ```ruby
15
- socket = UDPSocket.new
16
- socket.bind("127.0.0.1", 1234)
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
- socket.send "message-to-self", 0, "127.0.0.1", 1234
19
- p socket.recvfrom(10)
20
- #=> ["message-to", ["AF_INET", 4913, "localhost", "127.0.0.1"]]
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
 
@@ -3,7 +3,7 @@
3
3
  ## Installing
4
4
 
5
5
  ```bash
6
- $ gem install polyphony
6
+ $ gem install nuclear
7
7
  ```
8
8
 
9
9
  ## Tutorial
@@ -1,2 +1,4 @@
1
1
  # Tutorial
2
2
 
3
+
4
+
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  puts "going to sleep..."
8
7
  cancel_after(1) do
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  def echo(rchan, wchan)
8
7
  puts "start echoer"
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  enum = [1,2,3].each
8
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
5
5
 
6
6
  puts "parent pid: #{Process.pid}"
7
7
 
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  class GenServer
8
7
  def self.start(receiver, *args)
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  def loop_it(number, lock)
8
7
  loop do
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  puts "going to sleep..."
8
7
  move_on_after(1) do
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  puts "going to sleep..."
8
7
  move_on_after(1) do
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  puts "going to sleep..."
8
7
  move_on_after(0.5) do |scope|
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  spawn do
8
7
  puts "1 >"
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  spawn do
8
7
  puts "going to sleep"
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  async def sleep_and_cancel
8
7
  puts "#{Time.now} going to sleep with cancel..."
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  spawn do
8
7
  spawn do
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
3
+ require 'bundler/setup'
4
+ require 'polyphony'
4
5
 
5
- Polyphony = import('../../lib/polyphony')
6
-
7
- EV.next_tick do
6
+ next_tick do
8
7
  puts "two"
9
- EV.next_tick { puts "four" }
8
+ next_tick { puts "four" }
10
9
  puts "three"
11
10
  end
12
11
 
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  move_on_after(3) do
8
7
  pulser = pulse(1)
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  resource_count = 0
8
7
  Pool = Polyphony::ResourcePool.new(limit: 3) do
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  resource_count = 0
8
7
  Pool = Polyphony::ResourcePool.new(limit: 3) do
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  class Number
8
7
  def initialize(id)
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  puts "going to sleep..."
8
7
  sleep 1
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ require 'polyphony'
5
+
6
+ spawn {
7
+ 10.times { |i|
8
+ sleep 0.1;
9
+ p i
10
+ }
11
+ }
12
+
13
+ spawn {
14
+ puts "going to sleep..."
15
+ sleep 1
16
+ puts "woke up"
17
+ }.await
18
+
19
+ puts "done"
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  def my_sleep(t)
8
7
  puts "going to sleep..."
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  spawn do
8
7
  puts "going to sleep..."
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
3
+ require 'bundler/setup'
4
+ require 'polyphony'
4
5
 
5
- Polyphony = import('../../lib/polyphony')
6
6
  Polyphony.debug = true
7
7
 
8
8
  def error(t)
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  async def my_sleep(t)
8
7
  puts "#{t} start"
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  async def my_sleep(t)
8
7
  puts "start: #{t}"
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  async def my_sleep(t)
8
7
  sleep(t)
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  async def my_sleep(t)
8
7
  puts "start: #{t}"
@@ -1,16 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
- require 'digest'
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 = 100
10
+ X = 1000
14
11
 
15
12
  def blocking
16
13
  t0 = Time.now
@@ -1,10 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
- require 'digest'
5
- require 'socket'
6
-
7
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
8
5
 
9
6
  @op_count = 0
10
7
 
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
- require 'digest'
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/reality-ui.bmpr')
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'))
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony'
6
5
 
7
6
  spawn {
8
7
  throttled_loop(3) { STDOUT << '.' }
data/examples/fs/read.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
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
- X = 100
16
- Y = 10
17
-
18
- async def async_read_file
19
- X.times { IO.read(PATH) }
20
- end
21
-
22
- def do_read(supervisor, x)
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
- raw_read_file(X * Y)
27
-
28
- spawn do
25
+ def thread_pool_read_file(x, y)
29
26
  t0 = Time.now
30
27
  supervise do |s|
31
- 4.times { s.spawn async_read_file }
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 'modulation'
7
- Polyphony = import('../../lib/polyphony')
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 'modulation'
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 = 1
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"
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony/http'
6
5
 
7
6
  opts = { reuse_addr: true, dont_linger: true }
8
7
  spawn {
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
3
+ require 'bundler/setup'
4
+ require 'polyphony/http'
6
5
 
7
6
  opts = {
8
7
  reuse_addr: true,