polyphony 0.99 → 0.99.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -1
  3. data/.rubocop.yml +3 -3
  4. data/.yardopts +30 -0
  5. data/CHANGELOG.md +4 -0
  6. data/LICENSE +1 -1
  7. data/README.md +63 -29
  8. data/Rakefile +1 -5
  9. data/TODO.md +0 -4
  10. data/docs/{main-concepts/concurrency.md → concurrency.md} +2 -9
  11. data/docs/{main-concepts/design-principles.md → design-principles.md} +3 -9
  12. data/docs/{main-concepts/exception-handling.md → exception-handling.md} +2 -9
  13. data/docs/{main-concepts/extending.md → extending.md} +2 -9
  14. data/docs/faq.md +3 -16
  15. data/docs/{main-concepts/fiber-scheduling.md → fiber-scheduling.md} +1 -9
  16. data/docs/link_rewriter.rb +16 -0
  17. data/docs/{getting-started/overview.md → overview.md} +1 -30
  18. data/docs/{getting-started/tutorial.md → tutorial.md} +3 -28
  19. data/docs/{_posts/2020-07-26-polyphony-0.44.md → whats-new.md} +3 -1
  20. data/examples/adapters/redis_client.rb +3 -2
  21. data/examples/io/echo_server.rb +1 -1
  22. data/examples/io/echo_server_plain_ruby.rb +26 -0
  23. data/ext/polyphony/backend_io_uring.c +154 -9
  24. data/ext/polyphony/backend_io_uring_context.c +21 -12
  25. data/ext/polyphony/backend_io_uring_context.h +12 -7
  26. data/ext/polyphony/backend_libev.c +1 -1
  27. data/ext/polyphony/extconf.rb +24 -8
  28. data/ext/polyphony/fiber.c +79 -2
  29. data/ext/polyphony/io_extensions.c +53 -0
  30. data/ext/polyphony/pipe.c +42 -2
  31. data/ext/polyphony/polyphony.c +345 -31
  32. data/ext/polyphony/polyphony.h +9 -2
  33. data/ext/polyphony/queue.c +181 -0
  34. data/ext/polyphony/ring_buffer.c +0 -1
  35. data/ext/polyphony/runqueue.c +8 -1
  36. data/ext/polyphony/runqueue_ring_buffer.c +13 -0
  37. data/ext/polyphony/runqueue_ring_buffer.h +2 -1
  38. data/ext/polyphony/socket_extensions.c +6 -0
  39. data/ext/polyphony/thread.c +34 -2
  40. data/lib/polyphony/adapters/process.rb +11 -1
  41. data/lib/polyphony/adapters/sequel.rb +1 -1
  42. data/lib/polyphony/core/channel.rb +2 -0
  43. data/lib/polyphony/core/debug.rb +1 -1
  44. data/lib/polyphony/core/global_api.rb +25 -24
  45. data/lib/polyphony/core/resource_pool.rb +7 -6
  46. data/lib/polyphony/core/sync.rb +2 -2
  47. data/lib/polyphony/core/thread_pool.rb +3 -3
  48. data/lib/polyphony/core/timer.rb +8 -8
  49. data/lib/polyphony/extensions/exception.rb +2 -0
  50. data/lib/polyphony/extensions/fiber.rb +15 -13
  51. data/lib/polyphony/extensions/io.rb +127 -5
  52. data/lib/polyphony/extensions/kernel.rb +20 -2
  53. data/lib/polyphony/extensions/openssl.rb +100 -11
  54. data/lib/polyphony/extensions/pipe.rb +103 -7
  55. data/lib/polyphony/extensions/process.rb +13 -1
  56. data/lib/polyphony/extensions/socket.rb +93 -27
  57. data/lib/polyphony/extensions/thread.rb +9 -1
  58. data/lib/polyphony/extensions/timeout.rb +1 -1
  59. data/lib/polyphony/version.rb +2 -1
  60. data/lib/polyphony.rb +27 -7
  61. data/polyphony.gemspec +1 -8
  62. data/test/stress.rb +1 -1
  63. data/test/test_global_api.rb +45 -7
  64. data/test/test_socket.rb +96 -0
  65. data/test/test_timer.rb +5 -5
  66. metadata +17 -40
  67. data/docs/_config.yml +0 -64
  68. data/docs/_includes/head.html +0 -40
  69. data/docs/_includes/title.html +0 -1
  70. data/docs/_sass/custom/custom.scss +0 -10
  71. data/docs/_sass/overrides.scss +0 -0
  72. data/docs/api-reference/exception.md +0 -31
  73. data/docs/api-reference/fiber.md +0 -425
  74. data/docs/api-reference/index.md +0 -9
  75. data/docs/api-reference/io.md +0 -36
  76. data/docs/api-reference/object.md +0 -99
  77. data/docs/api-reference/polyphony-baseexception.md +0 -33
  78. data/docs/api-reference/polyphony-cancel.md +0 -26
  79. data/docs/api-reference/polyphony-moveon.md +0 -24
  80. data/docs/api-reference/polyphony-net.md +0 -20
  81. data/docs/api-reference/polyphony-process.md +0 -28
  82. data/docs/api-reference/polyphony-resourcepool.md +0 -59
  83. data/docs/api-reference/polyphony-restart.md +0 -18
  84. data/docs/api-reference/polyphony-terminate.md +0 -18
  85. data/docs/api-reference/polyphony-threadpool.md +0 -67
  86. data/docs/api-reference/polyphony-throttler.md +0 -77
  87. data/docs/api-reference/polyphony.md +0 -36
  88. data/docs/api-reference/thread.md +0 -88
  89. data/docs/favicon.ico +0 -0
  90. data/docs/getting-started/index.md +0 -10
  91. data/docs/getting-started/installing.md +0 -34
  92. /data/{docs/assets/img → assets}/echo-fibers.svg +0 -0
  93. /data/{docs → assets}/polyphony-logo.png +0 -0
  94. /data/{docs/assets/img → assets}/sleeping-fiber.svg +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4696bb7b13f68b379c29d5c38257e57c13aefd299f88727107e2f0f0a3c7d360
4
- data.tar.gz: 94a3eeb8575d0d5fe6f143ab41351024b50c4c4cf919edec6c8155d9ead2831e
3
+ metadata.gz: 3f9f6713f2080b0ad929afc680c52a88ad737701575c30433e9ec4c759258dd7
4
+ data.tar.gz: c7f3fd09e72c34269624d52d8dc77e9f5645cfa2d65743afe51e07db850598e3
5
5
  SHA512:
6
- metadata.gz: 9e1798e18b0e7a35104009d6f480191f5ed5efd7dee69189d443cb57ab8ca2f8fd75105234cd60f52ecea2348a8c3d85f152aa869374ea8dfbab8895a2015b04
7
- data.tar.gz: 835b2be245f60b04d5b750bcce6e679b11c671e31c3d0269aeafaa961c52c501193f67cf00f4f7cc5570cab499105d025863189767db8ae79f961a62d903b173
6
+ metadata.gz: d3472d5ffee0ce36370701c98d28d33d9c76e7ac21a6635e4dff063a6d28e313cd518290dbd0904c496ec29471cab39922daf2473f6b9a168588d0ef861f5ff2
7
+ data.tar.gz: 2a230e7c9b2a95e24992d4a844b92a7af243da5113f355945ce8f585a415dafbde0e2f1fe2fcd1ba434bda94992a3cdf906e37ab78c01caa355e131c8103c87b
data/.github/FUNDING.yml CHANGED
@@ -1 +1 @@
1
- github: ciconia
1
+ github: noteflakes
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.2
3
3
  RubyInterpreters:
4
4
  - ruby
5
5
  Exclude:
@@ -49,7 +49,7 @@ Style/NumericPredicate:
49
49
  Style/TrivialAccessors:
50
50
  Enabled: false
51
51
 
52
- Style/MethodMissingSuper:
52
+ Lint/MissingSuper:
53
53
  Enabled: false
54
54
 
55
55
  Style/GlobalVars:
@@ -90,7 +90,7 @@ Metrics/MethodLength:
90
90
 
91
91
  Metrics/ModuleLength:
92
92
  Exclude:
93
- - lib/polyphony/extensions/core.rb
93
+ - lib/polyphony/core/global_api.rb
94
94
  - examples/**/*.rb
95
95
 
96
96
  Metrics/ClassLength:
data/.yardopts ADDED
@@ -0,0 +1,30 @@
1
+ -o ./_yardoc
2
+ -m markdown -M redcarpet
3
+ --verbose
4
+ --protected
5
+ --no-private
6
+ --asset assets/:assets
7
+ --exclude debugger.rb
8
+ --exclude redis.rb
9
+ --exclude readline.rb
10
+ --exclude postgres.rb
11
+ --exclude zlib_conf.rb
12
+ --exclude extconf.rb
13
+ --exclude mysql2.rb
14
+ --exclude sequel.rb
15
+ --exclude event.c
16
+ --exclude backend.+\.c
17
+ --load ./docs/link_rewriter.rb
18
+ ./lib
19
+ ./ext/polyphony
20
+ -
21
+ docs/overview.md
22
+ docs/tutorial.md
23
+ docs/faq.md
24
+ docs/concurrency.md
25
+ docs/fiber-scheduling.md
26
+ docs/exception-handling.md
27
+ docs/extending.md
28
+ docs/design-principles.md
29
+ CHANGELOG.md
30
+ LICENSE
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.99.1 2023-05-08
2
+
3
+ - Reorganize docs, use Yard for all docs.
4
+
1
5
  ## 0.99 2023-03-09
2
6
 
3
7
  - Add missing Mutex API methods (#76)
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Sharon Rosner
3
+ Copyright (c) 2023 Sharon Rosner
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,36 +1,26 @@
1
- <h1 align="center">
2
- <a href="https://digital-fabric.github.io/polyphony/">
3
- <img src="docs/polyphony-logo.png" alt="Polyphony">
4
- </a>
5
- <br>
6
- Polyphony
7
- <br>
8
- </h1>
9
-
10
- <h4 align="center">Fine-Grained Concurrency for Ruby</h4>
11
-
12
- <p align="center">
13
- <a href="http://rubygems.org/gems/polyphony">
14
- <img src="https://badge.fury.io/rb/polyphony.svg" alt="Ruby gem">
15
- </a>
16
- <a href="https://github.com/digital-fabric/polyphony/actions?query=workflow%3ATests">
17
- <img src="https://github.com/digital-fabric/polyphony/workflows/Tests/badge.svg" alt="Tests">
18
- </a>
19
- <a href="https://github.com/digital-fabric/polyphony/blob/master/LICENSE">
20
- <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License">
21
- </a>
22
- </p>
23
-
24
- [DOCS](https://digital-fabric.github.io/polyphony/) |
25
- [EXAMPLES](examples)
1
+ <img src="assets/polyphony-logo.png" alt="Polyphony">
2
+
3
+ # Polyphony: Fine-Grained Concurrency for Ruby
4
+
5
+ <a href="http://rubygems.org/gems/polyphony">
6
+ <img src="https://badge.fury.io/rb/polyphony.svg" alt="Ruby gem">
7
+ </a>
8
+ <a href="https://github.com/digital-fabric/polyphony/actions?query=workflow%3ATests">
9
+ <img src="https://github.com/digital-fabric/polyphony/workflows/Tests/badge.svg" alt="Tests">
10
+ </a>
11
+ <a href="https://github.com/digital-fabric/polyphony/blob/master/LICENSE">
12
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License">
13
+ </a>
26
14
 
27
15
  > Polyphony \| pəˈlɪf\(ə\)ni \|
16
+ >
28
17
  > 1. _Music_ the style of simultaneously combining a number of parts, each
29
18
  > forming an individual melody and harmonizing with each other.
19
+ >
30
20
  > 2. _Programming_ a Ruby gem for concurrent programming focusing on performance
31
21
  > and developer happiness.
32
22
 
33
- ## What is Polyphony
23
+ ## What is Polyphony?
34
24
 
35
25
  Polyphony is a library for building concurrent applications in Ruby. Polyphony
36
26
  harnesses the power of [Ruby fibers](https://ruby-doc.org/core-2.5.1/Fiber.html)
@@ -54,10 +44,54 @@ the hood, Polyphony uses
54
44
  * Competitive performance and scalability characteristics, in terms of both
55
45
  throughput and memory consumption.
56
46
 
57
- ## Documentation
47
+ ## Installing
48
+
49
+ ### System Requirements
50
+
51
+ In order to use Polyphony you need to have:
52
+
53
+ - Linux or MacOS (support for Windows will come at a later stage)
54
+ - Ruby (MRI) 3.0 or newer
55
+
56
+ ### Installing the Polyphony Gem
57
+
58
+ Add this line to your application's Gemfile:
59
+
60
+ ```ruby
61
+ gem 'polyphony'
62
+ ```
63
+
64
+ And then execute:
65
+
66
+ ```bash
67
+ $ bundle
68
+ ```
69
+
70
+ Or install it yourself as:
71
+
72
+ ```bash
73
+ $ gem install polyphony
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ - [Overview](docs/overview.md)
79
+ - [Tutorial](docs/tutorial.md)
80
+ - [FAQ](docs/faq.md)
81
+
82
+ ## Technical Discussion
83
+
84
+ - [Concurrency the Easy Way](docs/concurrency.md)
85
+ - [How Fibers are Scheduled](docs/fiber-scheduling.md)
86
+ - [Exception Handling](docs/exception-handling.md)
87
+ - [Extending Polyphony](docs/extending.md)
88
+ - [Polyphony's Design](docs/design-principles.md)
89
+
90
+ ## Examples
58
91
 
59
- The complete documentation for Polyphony could be found on the
60
- [Polyphony website](https://digital-fabric.github.io/polyphony).
92
+ For examples of specific use cases you can consult the [bundled
93
+ examples](https://github.com/digital-fabric/polyphony/tree/master/examples) in
94
+ Polyphony's GitHub repository.
61
95
 
62
96
  ## Contributing to Polyphony
63
97
 
data/Rakefile CHANGED
@@ -19,16 +19,12 @@ task :stress_test do
19
19
  exec 'ruby test/stress.rb'
20
20
  end
21
21
 
22
- task :docs do
23
- exec 'RUBYOPT=-W0 jekyll serve -s docs -H ec2-18-156-117-172.eu-central-1.compute.amazonaws.com'
24
- end
25
-
26
22
  CLEAN.include "**/*.o", "**/*.so", "**/*.so.*", "**/*.a", "**/*.bundle", "**/*.jar", "pkg", "tmp"
27
23
 
28
24
  task :release do
29
25
  require_relative './lib/polyphony/version'
30
26
  version = Polyphony::VERSION
31
-
27
+
32
28
  puts 'Building polyphony...'
33
29
  `gem build polyphony.gemspec`
34
30
 
data/TODO.md CHANGED
@@ -11,9 +11,6 @@
11
11
  - Add support for IPv6:
12
12
  https://www.reddit.com/r/ruby/comments/lyen23/understanding_ipv6_and_why_its_important_to_you/
13
13
 
14
- - Add support for UDP sockets
15
-
16
- - Check segfault when resetting a `cancel_after` timeout lots of times at very high rate
17
14
  - Check why `throttled_loop` inside of `move_on_after` fails to stop
18
15
 
19
16
  - Override stock `::SizedQueue` impl with Queue with capacity
@@ -165,7 +162,6 @@
165
162
  - test performance
166
163
  - proceed from there
167
164
 
168
-
169
165
  ### Sinatra / Sidekiq
170
166
 
171
167
  - Pull out redis/postgres code, put into new `polyphony-xxx` gems
@@ -1,12 +1,5 @@
1
- ---
2
- layout: page
3
- title: Concurrency the Easy Way
4
- nav_order: 1
5
- parent: Main Concepts
6
- permalink: /main-concepts/concurrency/
7
- prev_title: Tutorial
8
- next_title: How Fibers are Scheduled
9
- ---
1
+ # @title Concurrency the Easy Way
2
+
10
3
  # Concurrency the Easy Way
11
4
 
12
5
  Concurrency is a major consideration for modern programmers. Applications and
@@ -1,12 +1,6 @@
1
- ---
2
- layout: page
3
- title: The Design of Polyphony
4
- nav_order: 5
5
- parent: Main Concepts
6
- permalink: /main-concepts/design-principles/
7
- prev_title: Extending Polyphony
8
- ---
9
- # The Design of Polyphony
1
+ # @title Polyphony's Design
2
+
3
+ # Polyphony's Design
10
4
 
11
5
  Polyphony is a new gem that aims to enable developing high-performance
12
6
  concurrent applications in Ruby using a fluent, compact syntax and API.
@@ -1,12 +1,5 @@
1
- ---
2
- layout: page
3
- title: Exception Handling
4
- nav_order: 3
5
- parent: Main Concepts
6
- permalink: /main-concepts/exception-handling/
7
- prev_title: How Fibers are Scheduled
8
- next_title: Extending Polyphony
9
- ---
1
+ # @title Exception Handling
2
+
10
3
  # Exception Handling
11
4
 
12
5
  Ruby employs a pretty robust exception handling mechanism. An raised exception
@@ -1,12 +1,5 @@
1
- ---
2
- layout: page
3
- title: Extending Polyphony
4
- nav_order: 4
5
- parent: Main Concepts
6
- permalink: /main-concepts/extending/
7
- prev_title: Exception Handling
8
- next_title: The Design of Polyphony
9
- ---
1
+ # @title Extending Polyphony
2
+
10
3
  # Extending Polyphony
11
4
 
12
5
  Polyphony was designed to ease the transition from blocking APIs and
data/docs/faq.md CHANGED
@@ -1,19 +1,6 @@
1
- ---
2
- layout: page
3
- title: Frequently Asked Questions
4
- nav_order: 100
5
- ---
1
+ # @title FAQ
6
2
 
7
3
  # Frequently Asked Questions
8
- {: .no_toc }
9
-
10
- ## Table of contents
11
- {: .no_toc .text-delta }
12
-
13
- - TOC
14
- {:toc}
15
-
16
- ---
17
4
 
18
5
  ## Why not just use callbacks instead of fibers?
19
6
 
@@ -191,5 +178,5 @@ Feel free to create issues and contribute pull requests.
191
178
  ## Who is behind this project?
192
179
 
193
180
  I'm Sharon Rosner, an independent software developer living in France. Here's my
194
- [github profile](https://github.com/ciconia). You can contact me by writing to
195
- [noteflakes@gmail.com](mailto:ciconia@gmail.com).
181
+ [github profile](https://github.com/noteflakes). You can contact me by writing to
182
+ [sharon@noteflakes.com](mailto:sharon@noteflakes.com).
@@ -1,12 +1,4 @@
1
- ---
2
- layout: page
3
- title: How Fibers are Scheduled
4
- nav_order: 2
5
- parent: Main Concepts
6
- permalink: /main-concepts/fiber-scheduling/
7
- prev_title: Concurrency the Easy Way
8
- next_title: Exception Handling
9
- ---
1
+ # @title How Fibers are Scheduled
10
2
 
11
3
  # How Fibers are Scheduled
12
4
 
@@ -0,0 +1,16 @@
1
+ require 'yard'
2
+
3
+ # shamelessly copied from https://github.com/troessner/reek/blob/master/docs/yard_plugin.rb
4
+
5
+ # Template helper to modify processing of links in HTML generated from our
6
+ # markdown files.
7
+ module LocalLinkHelper
8
+ # Rewrites links to (assumed local) markdown files so they're processed as
9
+ # {file: } directives.
10
+ def resolve_links(text)
11
+ text = text.gsub(%r{<a href="(docs/[^"]*.md)">([^<]*)</a>}, '{file:/\1 \2}')
12
+ super text
13
+ end
14
+ end
15
+
16
+ YARD::Templates::Template.extra_includes << LocalLinkHelper
@@ -1,20 +1,6 @@
1
- ---
2
- layout: page
3
- title: Overview
4
- parent: Getting Started
5
- nav_order: 2
6
- ---
1
+ # @title Overview
7
2
 
8
3
  # Polyphony - an Overview
9
- {: .no_toc }
10
-
11
- ## Table of contents
12
- {: .no_toc .text-delta }
13
-
14
- - TOC
15
- {:toc}
16
-
17
- ---
18
4
 
19
5
  ## Introduction
20
6
 
@@ -34,21 +20,6 @@ support for HTTP 1 & 2, WebSockets, TLS/SSL termination and more. Polyphony also
34
20
  provides fiber-aware adapters for connecting to PostgreSQL and Redis servers.
35
21
  More adapters are being actively developed.
36
22
 
37
- ### Features
38
- {: .no_toc }
39
-
40
- - Co-operative scheduling of concurrent tasks using Ruby fibers.
41
- - High-performance event reactor for handling I/O, timer, and other events.
42
- - Natural, sequential programming style that makes it easy to reason about
43
- concurrent code.
44
- - Abstractions and constructs for controlling the execution of concurrent code:
45
- supervisors, cancel scopes, throttling, resource pools etc.
46
- - Code can use native networking classes and libraries, growing support for
47
- third-party gems such as pg and redis.
48
- - Use stdlib classes such as TCPServer and TCPSocket and Net::HTTP.
49
- - Impressive performance and scalability characteristics, in terms of both
50
- throughput and memory consumption (see below)
51
-
52
23
  ## Taking Polyphony for a Spin
53
24
 
54
25
  Polyphony is different from other reactor-based solutions for Ruby in that
@@ -1,20 +1,6 @@
1
- ---
2
- layout: page
3
- title: Tutorial
4
- parent: Getting Started
5
- nav_order: 3
6
- ---
1
+ # @title Tutorial
7
2
 
8
3
  # Tutorial
9
- {: .no_toc }
10
-
11
- ## Table of contents
12
- {: .no_toc .text-delta }
13
-
14
- - TOC
15
- {:toc}
16
-
17
- ---
18
4
 
19
5
  Polyphony is a new Ruby library aimed at making writing concurrent Ruby apps
20
6
  easy and fun. In this article, we'll introduce Polyphony's fiber-based
@@ -108,7 +94,7 @@ The above program does nothing exceptional, it just sleeps for 1 second and
108
94
  prints a bunch of messages. But it is enough to demonstrate how concurrency
109
95
  works in Polyphony. Here's a flow chart of the transfer of control:
110
96
 
111
- <p class="img-figure"><img src="../../assets/img/sleeping-fiber.svg"></p>
97
+ <img src="../assets/sleeping-fiber.svg">
112
98
 
113
99
  Here's the actual sequence of execution (in pseudo-code)
114
100
 
@@ -203,7 +189,7 @@ innocent call to `#spin`.
203
189
 
204
190
  Here's a flow chart showing the transfer of control between the different fibers:
205
191
 
206
- <p class="img-figure"><img src="../../assets/img/echo-fibers.svg"></p>
192
+ <img src="../assets/echo-fibers.svg">
207
193
 
208
194
  Let's consider the advantage of the Polyphony concurrency model:
209
195
 
@@ -346,14 +332,3 @@ Polyphony currently provides support for any library that uses Ruby's stock
346
332
  `redis` and `irb` gems. It also includes an implementation of an integrated HTTP
347
333
  1 / HTTP 2 / websockets web server with support for TLS termination, ALPN
348
334
  protocol selection and preliminary rack support.
349
-
350
- ## Fibers are the Future!
351
-
352
- Implementing concurrency at the level of fibers opens up so many new
353
- possibilities for Ruby. Polyphony has the performance characteristics and
354
- provides the necessary tools for transforming how concurrent Ruby apps are
355
- written. Polyphony is still new, and the present documentation is far from being
356
- complete. To learn more about Polyphony, read the [technical
357
- overview](../../main-concepts/design-principles/). For more examples please
358
- consult the [Github
359
- repository](https://github.com/digital-fabric/polyphony/tree/master/examples).
@@ -1,4 +1,6 @@
1
- # Polyphony 0.44.1
1
+ # @title What's New?
2
+
3
+ # What's New in 0.44?
2
4
 
3
5
  ## More performance, more compatibility, more robustness
4
6
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/setup'
4
- require 'polyphony/adapters/redis'
3
+ # require 'bundler/setup'
4
+ require './lib/polyphony/adapters/redis'
5
+ require 'redis'
5
6
 
6
7
  ::Exception.__disable_sanitized_backtrace__ = true
7
8
 
@@ -5,8 +5,8 @@ require 'polyphony'
5
5
 
6
6
  spin_loop(interval: 5) { p Thread.backend.stats }
7
7
 
8
- server = TCPServer.open('127.0.0.1', 1234)
9
8
  puts "Pid: #{Process.pid}"
9
+ server = TCPServer.open('127.0.0.1', 1234)
10
10
  puts 'Echoing on port 1234...'
11
11
  begin
12
12
  while (client = server.accept)
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'socket'
4
+
5
+ puts "Pid: #{Process.pid}"
6
+ server = TCPServer.open('127.0.0.1', 1234)
7
+ puts 'Echoing on port 1234...'
8
+ begin
9
+ while (client = server.accept)
10
+ Thread.new do
11
+ while (data = client.gets)
12
+ # client.send("you said: #{data.chomp}!\n", 0)
13
+ client.write('you said: ', data.chomp, "!\n")
14
+ end
15
+ rescue Errno::ECONNRESET
16
+ 'Connection reset...'
17
+ ensure
18
+ puts "Closing client socket"
19
+ client.shutdown
20
+ client.close
21
+ end
22
+ end
23
+ ensure
24
+ puts "Closing server"
25
+ server.close
26
+ end