fibered_mysql2 0.4.0 → 1.0.0.colin.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a650c8b928698f83012667d045f865125f14d945386e479f266dfaf6bfa6758a
4
- data.tar.gz: abb22b1f34fde162c33fc58166015fe144e3f860505bf3041cfbf91410ba1dd3
3
+ metadata.gz: 75d1eaf3701caa8823cdfbec61e7d9734d1e5f463e7936010c5636715591c2c9
4
+ data.tar.gz: 715db9f2e07df69a6cf51a2389404f030cd9c257524544cb77c16f53de36b944
5
5
  SHA512:
6
- metadata.gz: a6b4efbdea49aaac1fb9ff515b3615cbbfaf7e126b609032c372081c26b6fa89f74b47f65217e6987613cd12b1a1157dd75cb143730a7d8f70f3c5b7fb2b21bb
7
- data.tar.gz: 45938b8becc0110038709167ce6f2f2624dab108b173a4daee7e5ea81deb891455a132111843d0fe3a1d6de7097a39f93a4769c6e6674a5dcfc6c81dc4f0d256
6
+ metadata.gz: 9a21b639b0b0ab6afcb558978a7e1060510e7fc7ca5e9a833b27d2b8c9eb49d023ac5beb5e0c500c3a3ff711d7f6ee0e49ae61f4e72f941c7a07420f60b9c866
7
+ data.tar.gz: 99adce5422229bdea37a08ed76a4dad71c6f4108ce3588d42dadc3b6c6fbb2895f65532842739dbe83cd7d6c748ea4b0cf7d57d05ca8fc26cbd0c6e65ab17e41
@@ -0,0 +1 @@
1
+ * @Invoca/octothorpe
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: FiberedMySQL2 Gem Build
3
- on: [push]
3
+ on: [push, pull_request]
4
4
  jobs:
5
5
  test:
6
6
  name: Unit Tests
@@ -8,11 +8,11 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [3.1, 3.2, 3.3]
11
+ ruby: [2.5, 2.6, 2.7, '3.0', 3.1]
12
12
  gemfile:
13
13
  - Gemfile
14
- - gemfiles/rails_7_0.gemfile
15
- - gemfiles/rails_7_1.gemfile
14
+ - gemfiles/rails_5.gemfile
15
+ - gemfiles/rails_6.gemfile
16
16
  env:
17
17
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
18
18
  steps:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.6
1
+ 3.2.1
data/Appraisals CHANGED
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "appraisal/matrix"
3
+ appraise 'rails-5' do
4
+ gem 'rails', '~> 5.2'
5
+ end
4
6
 
5
- appraisal_matrix(rails: [">= 7.0", "< 7.2"])
7
+ appraise 'rails-6' do
8
+ gem 'rails', '~> 6.0.0'
9
+ end
data/CHANGELOG.md CHANGED
@@ -4,33 +4,6 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [0.4.0] - 2025-08-21
8
- ### Added
9
- - Support for Rails 7.1.
10
-
11
- ### Removed
12
- - Removed support for Rails 6.
13
- - Removed usage of EventMachine::Synchrony ActiveRecord Mysql adapter. This adapter code was extremely old and we were overriding their patches back to the current ActiveRecord version.
14
-
15
- ## [0.3.1] - 2024-10-30
16
- ### Fixed
17
- - Fixed bug in FiberedMysqlAdapter.new_client that was causing `uninitialized constant` errors.
18
-
19
- ## [0.3.0] - 2024-10-23
20
- ### Added
21
- - Support for Rails 7.0.
22
-
23
- ### Removed
24
- - Removed support for Rails 6.0 and Rails 5.
25
-
26
- ### Changed
27
- - Clean up FiberedMysql2ConnectionFactory#fibered_mysql2_connection to better match Mysql2Adapter behavior.
28
- - Change FiberedMysql2::FiberedDatabaseConnectionPool#initialize to match ActiveRecord::ConnectionAdapters::ConnectionPool#initialize arguments.
29
-
30
- ## [0.2.1] - 2024-08-19
31
- ### Fixed
32
- - Fixed bugs in Rails 6.1
33
-
34
7
  ## [0.2.0] - 2023-01-12
35
8
  ### Added
36
9
  - Added support for Rails 6+ by adding knowledge of lazy transactions to the adapter.
data/Gemfile CHANGED
@@ -6,10 +6,11 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
6
  gemspec
7
7
 
8
8
  gem 'appraisal'
9
- gem 'appraisal-matrix'
9
+ gem 'coveralls', require: false
10
10
  gem 'mysql2', '~> 0.5'
11
- gem 'nokogiri'
12
- gem 'pry'
13
- gem 'pry-byebug'
14
- gem 'rake'
15
- gem 'rspec', '< 3.13'
11
+ gem 'nokogiri', '< 1.13'
12
+ gem 'pry', '~> 0.13'
13
+ gem 'pry-byebug', '~> 3.9'
14
+ gem 'rails', '< 6.1'
15
+ gem 'rake', '~> 13.0'
16
+ gem 'rspec', '~> 3.0'
data/Gemfile.lock CHANGED
@@ -1,247 +1,209 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fibered_mysql2 (0.4.0)
5
- em-synchrony (~> 1.0)
6
- rails (>= 7.0, < 7.2)
4
+ fibered_mysql2 (1.0.0.colin.1)
5
+ async
6
+ rails (>= 5.2, < 7)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.1.5.2)
12
- actionpack (= 7.1.5.2)
13
- activesupport (= 7.1.5.2)
11
+ actioncable (6.0.3.4)
12
+ actionpack (= 6.0.3.4)
14
13
  nio4r (~> 2.0)
15
14
  websocket-driver (>= 0.6.1)
16
- zeitwerk (~> 2.6)
17
- actionmailbox (7.1.5.2)
18
- actionpack (= 7.1.5.2)
19
- activejob (= 7.1.5.2)
20
- activerecord (= 7.1.5.2)
21
- activestorage (= 7.1.5.2)
22
- activesupport (= 7.1.5.2)
15
+ actionmailbox (6.0.3.4)
16
+ actionpack (= 6.0.3.4)
17
+ activejob (= 6.0.3.4)
18
+ activerecord (= 6.0.3.4)
19
+ activestorage (= 6.0.3.4)
20
+ activesupport (= 6.0.3.4)
23
21
  mail (>= 2.7.1)
24
- net-imap
25
- net-pop
26
- net-smtp
27
- actionmailer (7.1.5.2)
28
- actionpack (= 7.1.5.2)
29
- actionview (= 7.1.5.2)
30
- activejob (= 7.1.5.2)
31
- activesupport (= 7.1.5.2)
22
+ actionmailer (6.0.3.4)
23
+ actionpack (= 6.0.3.4)
24
+ actionview (= 6.0.3.4)
25
+ activejob (= 6.0.3.4)
32
26
  mail (~> 2.5, >= 2.5.4)
33
- net-imap
34
- net-pop
35
- net-smtp
36
- rails-dom-testing (~> 2.2)
37
- actionpack (7.1.5.2)
38
- actionview (= 7.1.5.2)
39
- activesupport (= 7.1.5.2)
40
- nokogiri (>= 1.8.5)
41
- racc
42
- rack (>= 2.2.4)
43
- rack-session (>= 1.0.1)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.0.3.4)
29
+ actionview (= 6.0.3.4)
30
+ activesupport (= 6.0.3.4)
31
+ rack (~> 2.0, >= 2.0.8)
44
32
  rack-test (>= 0.6.3)
45
- rails-dom-testing (~> 2.2)
46
- rails-html-sanitizer (~> 1.6)
47
- actiontext (7.1.5.2)
48
- actionpack (= 7.1.5.2)
49
- activerecord (= 7.1.5.2)
50
- activestorage (= 7.1.5.2)
51
- activesupport (= 7.1.5.2)
52
- globalid (>= 0.6.0)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.0.3.4)
36
+ actionpack (= 6.0.3.4)
37
+ activerecord (= 6.0.3.4)
38
+ activestorage (= 6.0.3.4)
39
+ activesupport (= 6.0.3.4)
53
40
  nokogiri (>= 1.8.5)
54
- actionview (7.1.5.2)
55
- activesupport (= 7.1.5.2)
41
+ actionview (6.0.3.4)
42
+ activesupport (= 6.0.3.4)
56
43
  builder (~> 3.1)
57
- erubi (~> 1.11)
58
- rails-dom-testing (~> 2.2)
59
- rails-html-sanitizer (~> 1.6)
60
- activejob (7.1.5.2)
61
- activesupport (= 7.1.5.2)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.0.3.4)
48
+ activesupport (= 6.0.3.4)
62
49
  globalid (>= 0.3.6)
63
- activemodel (7.1.5.2)
64
- activesupport (= 7.1.5.2)
65
- activerecord (7.1.5.2)
66
- activemodel (= 7.1.5.2)
67
- activesupport (= 7.1.5.2)
68
- timeout (>= 0.4.0)
69
- activestorage (7.1.5.2)
70
- actionpack (= 7.1.5.2)
71
- activejob (= 7.1.5.2)
72
- activerecord (= 7.1.5.2)
73
- activesupport (= 7.1.5.2)
74
- marcel (~> 1.0)
75
- activesupport (7.1.5.2)
76
- base64
77
- benchmark (>= 0.3)
78
- bigdecimal
50
+ activemodel (6.0.3.4)
51
+ activesupport (= 6.0.3.4)
52
+ activerecord (6.0.3.4)
53
+ activemodel (= 6.0.3.4)
54
+ activesupport (= 6.0.3.4)
55
+ activestorage (6.0.3.4)
56
+ actionpack (= 6.0.3.4)
57
+ activejob (= 6.0.3.4)
58
+ activerecord (= 6.0.3.4)
59
+ marcel (~> 0.3.1)
60
+ activesupport (6.0.3.4)
79
61
  concurrent-ruby (~> 1.0, >= 1.0.2)
80
- connection_pool (>= 2.2.5)
81
- drb
82
- i18n (>= 1.6, < 2)
83
- logger (>= 1.4.2)
84
- minitest (>= 5.1)
85
- mutex_m
86
- securerandom (>= 0.3)
87
- tzinfo (~> 2.0)
88
- appraisal (2.5.0)
62
+ i18n (>= 0.7, < 2)
63
+ minitest (~> 5.1)
64
+ tzinfo (~> 1.1)
65
+ zeitwerk (~> 2.2, >= 2.2.2)
66
+ appraisal (2.4.0)
89
67
  bundler
90
68
  rake
91
69
  thor (>= 0.14.0)
92
- appraisal-matrix (0.3.0)
93
- appraisal (~> 2.2)
94
- base64 (0.3.0)
95
- benchmark (0.4.1)
96
- bigdecimal (3.2.2)
97
- builder (3.3.0)
98
- byebug (12.0.0)
99
- cgi (0.5.0)
70
+ async (2.5.1)
71
+ console (~> 1.10)
72
+ io-event (~> 1.1)
73
+ timers (~> 4.1)
74
+ builder (3.2.4)
75
+ byebug (11.1.3)
100
76
  coderay (1.1.3)
101
- concurrent-ruby (1.3.5)
102
- connection_pool (2.5.3)
77
+ concurrent-ruby (1.1.8)
78
+ console (1.16.2)
79
+ fiber-local
80
+ coveralls (0.8.23)
81
+ json (>= 1.8, < 3)
82
+ simplecov (~> 0.16.1)
83
+ term-ansicolor (~> 1.3)
84
+ thor (>= 0.19.4, < 2.0)
85
+ tins (~> 1.6)
103
86
  crass (1.0.6)
104
- date (3.4.1)
105
- diff-lcs (1.6.2)
106
- drb (2.2.3)
107
- em-synchrony (1.0.6)
108
- eventmachine (>= 1.0.0.beta.1)
109
- erb (4.0.4)
110
- cgi (>= 0.3.3)
111
- erubi (1.13.1)
112
- eventmachine (1.2.7)
113
- globalid (1.2.1)
114
- activesupport (>= 6.1)
115
- i18n (1.14.7)
87
+ diff-lcs (1.4.4)
88
+ docile (1.3.2)
89
+ erubi (1.10.0)
90
+ fiber-local (1.0.0)
91
+ globalid (0.4.2)
92
+ activesupport (>= 4.2.0)
93
+ i18n (1.8.7)
116
94
  concurrent-ruby (~> 1.0)
117
- io-console (0.8.1)
118
- irb (1.15.2)
119
- pp (>= 0.6.0)
120
- rdoc (>= 4.0.0)
121
- reline (>= 0.4.2)
122
- logger (1.7.0)
123
- loofah (2.24.1)
95
+ io-event (1.2.2)
96
+ json (2.3.1)
97
+ loofah (2.8.0)
124
98
  crass (~> 1.0.2)
125
- nokogiri (>= 1.12.0)
126
- mail (2.8.1)
99
+ nokogiri (>= 1.5.9)
100
+ mail (2.7.1)
127
101
  mini_mime (>= 0.1.1)
128
- net-imap
129
- net-pop
130
- net-smtp
131
- marcel (1.0.4)
132
- method_source (1.1.0)
133
- mini_mime (1.1.5)
134
- mini_portile2 (2.8.9)
135
- minitest (5.25.5)
136
- mutex_m (0.3.0)
137
- mysql2 (0.5.6)
138
- net-imap (0.5.9)
139
- date
140
- net-protocol
141
- net-pop (0.1.2)
142
- net-protocol
143
- net-protocol (0.2.2)
144
- timeout
145
- net-smtp (0.5.1)
146
- net-protocol
147
- nio4r (2.7.4)
148
- nokogiri (1.18.9)
149
- mini_portile2 (~> 2.8.2)
102
+ marcel (0.3.3)
103
+ mimemagic (~> 0.3.2)
104
+ method_source (1.0.0)
105
+ mimemagic (0.3.10)
106
+ nokogiri (~> 1)
107
+ rake
108
+ mini_mime (1.0.2)
109
+ mini_portile2 (2.6.1)
110
+ minitest (5.14.3)
111
+ mysql2 (0.5.5)
112
+ nio4r (2.5.4)
113
+ nokogiri (1.12.5)
114
+ mini_portile2 (~> 2.6.1)
150
115
  racc (~> 1.4)
151
- pp (0.6.2)
152
- prettyprint
153
- prettyprint (0.2.0)
154
- pry (0.15.2)
116
+ pry (0.13.1)
155
117
  coderay (~> 1.1)
156
118
  method_source (~> 1.0)
157
- pry-byebug (3.11.0)
158
- byebug (~> 12.0)
159
- pry (>= 0.13, < 0.16)
160
- psych (5.2.6)
161
- date
162
- stringio
163
- racc (1.8.1)
164
- rack (3.2.0)
165
- rack-session (2.1.1)
166
- base64 (>= 0.1.0)
167
- rack (>= 3.0.0)
168
- rack-test (2.2.0)
169
- rack (>= 1.3)
170
- rackup (2.2.1)
171
- rack (>= 3)
172
- rails (7.1.5.2)
173
- actioncable (= 7.1.5.2)
174
- actionmailbox (= 7.1.5.2)
175
- actionmailer (= 7.1.5.2)
176
- actionpack (= 7.1.5.2)
177
- actiontext (= 7.1.5.2)
178
- actionview (= 7.1.5.2)
179
- activejob (= 7.1.5.2)
180
- activemodel (= 7.1.5.2)
181
- activerecord (= 7.1.5.2)
182
- activestorage (= 7.1.5.2)
183
- activesupport (= 7.1.5.2)
184
- bundler (>= 1.15.0)
185
- railties (= 7.1.5.2)
186
- rails-dom-testing (2.3.0)
187
- activesupport (>= 5.0.0)
188
- minitest
119
+ pry-byebug (3.9.0)
120
+ byebug (~> 11.0)
121
+ pry (~> 0.13.0)
122
+ racc (1.6.0)
123
+ rack (2.2.3)
124
+ rack-test (1.1.0)
125
+ rack (>= 1.0, < 3)
126
+ rails (6.0.3.4)
127
+ actioncable (= 6.0.3.4)
128
+ actionmailbox (= 6.0.3.4)
129
+ actionmailer (= 6.0.3.4)
130
+ actionpack (= 6.0.3.4)
131
+ actiontext (= 6.0.3.4)
132
+ actionview (= 6.0.3.4)
133
+ activejob (= 6.0.3.4)
134
+ activemodel (= 6.0.3.4)
135
+ activerecord (= 6.0.3.4)
136
+ activestorage (= 6.0.3.4)
137
+ activesupport (= 6.0.3.4)
138
+ bundler (>= 1.3.0)
139
+ railties (= 6.0.3.4)
140
+ sprockets-rails (>= 2.0.0)
141
+ rails-dom-testing (2.0.3)
142
+ activesupport (>= 4.2.0)
189
143
  nokogiri (>= 1.6)
190
- rails-html-sanitizer (1.6.2)
191
- loofah (~> 2.21)
192
- nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
193
- railties (7.1.5.2)
194
- actionpack (= 7.1.5.2)
195
- activesupport (= 7.1.5.2)
196
- irb
197
- rackup (>= 1.0.0)
198
- rake (>= 12.2)
199
- thor (~> 1.0, >= 1.2.2)
200
- zeitwerk (~> 2.6)
201
- rake (13.3.0)
202
- rdoc (6.14.2)
203
- erb
204
- psych (>= 4.0.0)
205
- reline (0.6.2)
206
- io-console (~> 0.5)
207
- rspec (3.12.0)
208
- rspec-core (~> 3.12.0)
209
- rspec-expectations (~> 3.12.0)
210
- rspec-mocks (~> 3.12.0)
211
- rspec-core (3.12.2)
212
- rspec-support (~> 3.12.0)
213
- rspec-expectations (3.12.3)
144
+ rails-html-sanitizer (1.3.0)
145
+ loofah (~> 2.3)
146
+ railties (6.0.3.4)
147
+ actionpack (= 6.0.3.4)
148
+ activesupport (= 6.0.3.4)
149
+ method_source
150
+ rake (>= 0.8.7)
151
+ thor (>= 0.20.3, < 2.0)
152
+ rake (13.0.6)
153
+ rspec (3.9.0)
154
+ rspec-core (~> 3.9.0)
155
+ rspec-expectations (~> 3.9.0)
156
+ rspec-mocks (~> 3.9.0)
157
+ rspec-core (3.9.3)
158
+ rspec-support (~> 3.9.3)
159
+ rspec-expectations (3.9.2)
214
160
  diff-lcs (>= 1.2.0, < 2.0)
215
- rspec-support (~> 3.12.0)
216
- rspec-mocks (3.12.6)
161
+ rspec-support (~> 3.9.0)
162
+ rspec-mocks (3.9.1)
217
163
  diff-lcs (>= 1.2.0, < 2.0)
218
- rspec-support (~> 3.12.0)
219
- rspec-support (3.12.1)
220
- securerandom (0.4.1)
221
- stringio (3.1.7)
222
- thor (1.4.0)
223
- timeout (0.4.3)
224
- tzinfo (2.0.6)
164
+ rspec-support (~> 3.9.0)
165
+ rspec-support (3.9.3)
166
+ simplecov (0.16.1)
167
+ docile (~> 1.1)
168
+ json (>= 1.8, < 3)
169
+ simplecov-html (~> 0.10.0)
170
+ simplecov-html (0.10.2)
171
+ sprockets (4.0.2)
225
172
  concurrent-ruby (~> 1.0)
226
- websocket-driver (0.8.0)
227
- base64
173
+ rack (> 1, < 3)
174
+ sprockets-rails (3.2.2)
175
+ actionpack (>= 4.0)
176
+ activesupport (>= 4.0)
177
+ sprockets (>= 3.0.0)
178
+ sync (0.5.0)
179
+ term-ansicolor (1.7.1)
180
+ tins (~> 1.0)
181
+ thor (1.0.1)
182
+ thread_safe (0.3.6)
183
+ timers (4.3.5)
184
+ tins (1.25.0)
185
+ sync
186
+ tzinfo (1.2.9)
187
+ thread_safe (~> 0.1)
188
+ websocket-driver (0.7.3)
228
189
  websocket-extensions (>= 0.1.0)
229
190
  websocket-extensions (0.1.5)
230
- zeitwerk (2.6.18)
191
+ zeitwerk (2.4.1)
231
192
 
232
193
  PLATFORMS
233
194
  ruby
234
195
 
235
196
  DEPENDENCIES
236
197
  appraisal
237
- appraisal-matrix
198
+ coveralls
238
199
  fibered_mysql2!
239
200
  mysql2 (~> 0.5)
240
- nokogiri
241
- pry
242
- pry-byebug
243
- rake
244
- rspec (< 3.13)
201
+ nokogiri (< 1.13)
202
+ pry (~> 0.13)
203
+ pry-byebug (~> 3.9)
204
+ rails (< 6.1)
205
+ rake (~> 13.0)
206
+ rspec (~> 3.0)
245
207
 
246
208
  BUNDLED WITH
247
209
  2.2.29
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- spec.add_dependency 'em-synchrony', '~> 1.0'
33
- spec.add_dependency 'rails', '>= 7.0', '< 7.2'
32
+ spec.add_dependency 'async'
33
+ spec.add_dependency 'rails', '>= 5.2', '< 7'
34
34
  end
@@ -0,0 +1,15 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "coveralls", require: false
7
+ gem "mysql2", "~> 0.5"
8
+ gem "nokogiri", "< 1.13"
9
+ gem "pry", "~> 0.13"
10
+ gem "pry-byebug", "~> 3.9"
11
+ gem "rails", "~> 5.2"
12
+ gem "rake", "~> 13.0"
13
+ gem "rspec", "~> 3.0"
14
+
15
+ gemspec path: "../"
@@ -0,0 +1,15 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "coveralls", require: false
7
+ gem "mysql2", "~> 0.5"
8
+ gem "nokogiri", "< 1.13"
9
+ gem "pry", "~> 0.13"
10
+ gem "pry-byebug", "~> 3.9"
11
+ gem "rails", "~> 6.0.0"
12
+ gem "rake", "~> 13.0"
13
+ gem "rspec", "~> 3.0"
14
+
15
+ gemspec path: "../"
@@ -1,105 +1,76 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'em-synchrony'
4
3
  require 'active_model'
5
4
  require 'active_record/errors'
6
5
  require 'active_record/connection_adapters/mysql2_adapter'
7
- require 'em-synchrony/mysql2'
6
+ require_relative '../../fibered_mysql2/async_task'
8
7
 
9
8
  module FiberedMysql2
10
- module FiberedMysql2Adapter_7_0
9
+ module FiberedMysql2Adapter_6
11
10
  def lease
12
- if in_use?
13
- msg = "Cannot lease connection, ".dup
14
- if owner_fiber == Fiber.current
15
- msg << "it is already leased by the current fiber."
11
+ if (ot = owner_task)
12
+ msg = +"Cannot lease connection; "
13
+ if ot == (current_task = AsyncTask.current_or_none)
14
+ msg << "it is already leased by the current Async::Task."
16
15
  else
17
- msg << "it is already in use by a different fiber: #{owner_fiber}. " \
18
- "Current fiber: #{Fiber.current}."
16
+ msg << "it is already in use by a different Async::Task: #{ot}. " \
17
+ "Current Async::Task: #{current_task}."
19
18
  end
20
19
  raise ::ActiveRecord::ActiveRecordError, msg
21
20
  end
22
21
 
23
- @owner = Fiber.current
22
+ @owner = AsyncTask.current_or_none
24
23
  end
25
24
 
26
25
  def expire
27
- if in_use?
28
- # Because we are actively releasing connections from dead fibers, we only want
29
- # to enforce that we're expiring the current fibers connection, iff the owner
26
+ if (ot = owner_task)
27
+ # Because we are actively releasing connections from dead tasks, we only want
28
+ # to enforce that we're expiring the current task's connection, iff the owner
30
29
  # of the connection is still alive.
31
- if owner_fiber.alive? && owner_fiber != Fiber.current
32
- raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, " \
33
- "it is owned by a different fiber: #{owner_fiber}. " \
34
- "Current fiber: #{Fiber.current}."
30
+ if ot.alive? && ot != (current_task = AsyncTask.current_or_none)
31
+ raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection; " \
32
+ "it is owned by a different Async::Task: #{ot}. " \
33
+ "Current Async::Task: #{current_task}."
35
34
  end
36
35
 
37
36
  @idle_since = ::Concurrent.monotonic_time
38
37
  @owner = nil
39
38
  else
40
- raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, it is not currently leased."
39
+ raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection; it is not currently leased."
41
40
  end
42
41
  end
43
42
 
44
43
  def steal!
45
- if in_use?
46
- if owner_fiber != Fiber.current
47
- pool.send :remove_connection_from_thread_cache, self, owner_fiber
44
+ if (ot = owner_task)
45
+ if ot != (current_task = AsyncTask.current_or_none)
46
+ pool.send :remove_connection_from_thread_cache, self, ot
48
47
 
49
- @owner = Fiber.current
48
+ @owner = current_task
50
49
  end
51
50
  else
52
- raise ::ActiveRecord::ActiveRecordError, "Cannot steal connection, it is not currently leased."
51
+ raise ::ActiveRecord::ActiveRecordError, "Cannot steal connection; it is not currently leased."
53
52
  end
54
53
  end
55
54
 
56
55
  private
57
56
 
58
- def owner_fiber
59
- @owner.nil? || @owner.is_a?(Fiber) or
60
- raise "@owner must be a Fiber! Found #{@owner.inspect}"
57
+ def owner_task
58
+ @owner.nil? || @owner == AsyncTask::NoTaskPlaceholder || @owner.is_a?(Async::Task) or
59
+ raise "@owner must be an Async::Task or FiberedMysql2::AsyncTask::NoTaskPlaceholder! Found #{@owner.inspect}"
61
60
  @owner
62
61
  end
63
62
  end
64
63
 
65
- module FiberedMysql2Adapter_7_1
66
- def expire
67
- if in_use?
68
- # Because we are actively releasing connections from dead fibers, we only want
69
- # to enforce that we're expiring the current fibers connection, iff the owner
70
- # of the connection is still alive.
71
- if @owner.alive? && @owner != ActiveSupport::IsolatedExecutionState.context
72
- raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, " \
73
- "it is owned by a different fiber: #{@owner}. " \
74
- "Current fiber: #{ActiveSupport::IsolatedExecutionState.context}."
75
- end
76
-
77
- @idle_since = Process.clock_gettime(Process::CLOCK_MONOTONIC)
78
- @owner = nil
79
- else
80
- raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, it is not currently leased."
81
- end
82
- end
83
- end
84
-
85
64
  class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
86
- if Rails.gem_version < "7.1"
87
- include FiberedMysql2Adapter_7_0
65
+ case ::Rails::VERSION::MAJOR
66
+ when 6
67
+ include FiberedMysql2Adapter_6
88
68
  else
89
- include FiberedMysql2Adapter_7_1
69
+ raise ArgumentError, "unexpected Rails version #{Rails::VERSION::MAJOR}"
90
70
  end
91
71
 
92
- class << self
93
- # Copied from Mysql2Adapter, except with the EM Mysql2 client
94
- def new_client(config)
95
- Mysql2::EM::Client.new(config)
96
- rescue Mysql2::Error => error
97
- if error.error_number == 1049
98
- raise ActiveRecord::NoDatabaseError.new, error.message
99
- else
100
- raise ActiveRecord::ConnectionNotEstablished, error.message
101
- end
102
- end
72
+ def initialize(*args)
73
+ super
103
74
  end
104
75
  end
105
76
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FiberedMysql2
4
+ module AsyncTask
5
+ class NoTaskPlaceholder
6
+ class << self
7
+ def alive? = true
8
+ end
9
+ end
10
+
11
+ class << self
12
+ # Adapted from https://github.com/socketry/async/blob/main/lib/async/task.rb#L236-L238
13
+ def current_or_none
14
+ Thread.current[:async_task] || NoTaskPlaceholder
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,227 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This class behaves the same as ActiveRecord's ConnectionPool, but synchronizes with fibers rather than threads.
3
+ # This class behaves the same as ActiveRecord's ConnectionPool, but synchronizes with Async::Task fibers rather than threads.
4
4
 
5
5
  # Note - trace statements have been commented out. This is useful trace but we do not want it on by default.
6
6
  # When we have configurable logging we can put this back and have it off by default.
7
7
 
8
- require 'em-synchrony'
9
- require 'em-synchrony/thread'
10
- require 'fibered_mysql2/fibered_mutex_with_waiter_priority'
11
-
12
- EventMachine::Synchrony::Thread::Mutex.prepend(FiberedMysql2::FiberedMutexWithWaiterPriority)
13
-
14
8
  module FiberedMysql2
15
- class FiberedConditionVariable
16
- EXCEPTION_NEVER = {Exception => :never}.freeze
17
- EXCEPTION_IMMEDIATE = {Exception => :immediate}.freeze
18
-
19
- #
20
- # FIXME: This isn't documented in Nutshell.
21
- #
22
- # Since MonitorMixin.new_cond returns a ConditionVariable, and the example
23
- # above calls while_wait and signal, this class should be documented.
24
- #
25
- class Timeout < Exception; end
26
-
27
- #
28
- # Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
29
- #
30
- # If +timeout+ is given, this method returns after +timeout+ seconds passed,
31
- # even if no other thread doesn't signal.
32
- #
33
- def wait(timeout = nil)
34
- Thread.handle_interrupt(EXCEPTION_NEVER) do
35
- @monitor.__send__(:mon_check_owner)
36
- count = @monitor.__send__(:mon_exit_for_cond)
37
- begin
38
- Thread.handle_interrupt(EXCEPTION_IMMEDIATE) do
39
- @cond.wait(@monitor.instance_variable_get(:@mon_mutex), timeout)
40
- end
41
- return true
42
- ensure
43
- @monitor.__send__(:mon_enter_for_cond, count)
44
- end
45
- end
46
- end
47
-
48
- #
49
- # Calls wait repeatedly while the given block yields a truthy value.
50
- #
51
- def wait_while
52
- while yield
53
- wait
54
- end
55
- end
56
-
57
- #
58
- # Calls wait repeatedly until the given block yields a truthy value.
59
- #
60
- def wait_until
61
- until yield
62
- wait
63
- end
64
- end
65
-
66
- #
67
- # Wakes up the first thread in line waiting for this lock.
68
- #
69
- def signal
70
- @monitor.__send__(:mon_check_owner)
71
- @cond.signal
72
- end
73
-
74
- #
75
- # Wakes up all threads waiting for this lock.
76
- #
77
- def broadcast
78
- @monitor.__send__(:mon_check_owner)
79
- @cond.broadcast
80
- end
81
-
82
- def initialize(monitor)
83
- @monitor = monitor
84
- @cond = EM::Synchrony::Thread::ConditionVariable.new
85
- end
86
- end
87
-
88
- # From Ruby's MonitorMixin, with all occurrences of Thread changed to Fiber
89
- module FiberedMonitorMixin
90
- def self.extend_object(obj)
91
- super
92
- obj.__send__(:mon_initialize)
93
- end
94
-
95
- #
96
- # Attempts to enter exclusive section. Returns +false+ if lock fails.
97
- #
98
- def mon_try_enter
99
- if @mon_owner != Fiber.current
100
- @mon_mutex.try_lock or return false
101
- @mon_owner = Fiber.current
102
- @mon_count = 0
103
- end
104
- @mon_count += 1
105
- true
9
+ module FiberedDatabaseConnectionPool
10
+ case ::Rails::VERSION::MAJOR
11
+ when 6
12
+ else
13
+ raise ArgumentError, "unexpected Rails version #{Rails::VERSION::MAJOR}"
106
14
  end
107
15
 
108
- #
109
- # Enters exclusive section.
110
- #
111
- def mon_enter
112
- if @mon_owner != Fiber.current
113
- @mon_mutex.lock
114
- @mon_owner = Fiber.current
115
- @mon_count = 0
116
- end
117
- @mon_count += 1
16
+ def cached_connections
17
+ @thread_cached_conns
118
18
  end
119
19
 
120
- #
121
- # Leaves exclusive section.
122
- #
123
- def mon_exit
124
- mon_check_owner
125
- @mon_count -= 1
126
- if @mon_count == 0
127
- @mon_owner = nil
128
- @mon_mutex.unlock
129
- end
20
+ def current_connection_id
21
+ connection_cache_key(current_thread)
130
22
  end
131
23
 
132
- #
133
- # Enters exclusive section and executes the block. Leaves the exclusive
134
- # section automatically when the block exits. See example under
135
- # +MonitorMixin+.
136
- #
137
- def mon_synchronize
138
- mon_enter
24
+ def checkout(checkout_timeout = @checkout_timeout)
139
25
  begin
140
- yield
141
- ensure
142
- begin
143
- mon_exit
144
- rescue => ex
145
- ActiveRecord::Base.logger.error("Exception occurred while executing mon_exit: #{ex}")
146
- end
26
+ reap_connections
27
+ rescue => ex
28
+ ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex.class}: #{ex.message}")
147
29
  end
30
+ super
148
31
  end
149
- alias synchronize mon_synchronize
150
-
151
- #
152
- # Creates a new FiberedConditionVariable associated with the
153
- # receiver.
154
- #
155
- def new_cond
156
- FiberedConditionVariable.new(self)
157
- end
158
-
159
- # Initializes the FiberedMonitorMixin after being included in a class
160
- def mon_initialize
161
- @mon_owner = nil
162
- @mon_count = 0
163
- @mon_mutex = EM::Synchrony::Thread::Mutex.new
164
- end
165
-
166
- def mon_check_owner
167
- @mon_owner == Fiber.current or raise FiberError, "current fiber not owner"
168
- end
169
-
170
- private
171
-
172
- def mon_enter_for_cond(count)
173
- @mon_owner = Fiber.current
174
- @mon_count = count
175
- end
176
-
177
- # returns the old mon_count
178
- def mon_exit_for_cond
179
- count = @mon_count
180
- @mon_owner = nil
181
- @mon_count = 0
182
- count
183
- end
184
- end
185
-
186
- module FiberedDatabaseConnectionPool
187
- include FiberedMonitorMixin
188
-
189
- # Methods that only need to be made Fiber safe in Rails 7.0. Rails 7.1 properly supports Fibers for these methods.
190
- module Adapter_7_0
191
- def release_connection(owner_thread = Fiber.current)
192
- if (conn = @thread_cached_conns.delete(connection_cache_key(owner_thread)))
193
- checkin(conn)
194
- end
195
- end
196
-
197
- def with_connection
198
- unless (conn = cached_connections[current_connection_id])
199
- conn = connection
200
- fresh_connection = true
201
- end
202
- yield conn
203
- ensure
204
- release_connection if fresh_connection
205
- end
206
-
207
- private
208
32
 
209
- def current_thread
210
- Fiber.current
33
+ def release_connection(owner_task = AsyncTask.current_or_none)
34
+ if (conn = @thread_cached_conns.delete(connection_cache_key(owner_task)))
35
+ checkin(conn)
211
36
  end
212
37
  end
213
- if ActiveRecord.gem_version < "7.1"
214
- include Adapter_7_0
215
- end
216
38
 
217
- def initialize(pool_config)
218
- if pool_config.db_config.reaping_frequency
219
- pool_config.db_config.reaping_frequency > 0 and raise "reaping_frequency is not supported (the ActiveRecord Reaper is thread-based)"
220
- end
39
+ def initialize(connection_spec, *args, **keyword_args)
40
+ connection_spec.config[:reaping_frequency] and raise "reaping_frequency is not supported (the ActiveRecord Reaper is thread-based)"
41
+ connection_spec.config[:reaping_frequency] = nil # starting in Rails 5, this defaults to 60 if not explicitly set
221
42
 
222
- super(pool_config)
43
+ super(connection_spec, *args, **keyword_args)
223
44
 
224
45
  @reaper = nil # no need to keep a reference to this since it does nothing in this sub-class
46
+
47
+ # note that @reserved_connections is a ThreadSafe::Cache which is overkill in a fibered world, but harmless
225
48
  end
226
49
 
227
50
  def connection
@@ -240,21 +63,6 @@ module FiberedMysql2
240
63
  end
241
64
  end
242
65
 
243
- # Invoca Patch - Reap connections so we re-use any orphaned connections instead of creating a new connection.
244
- # This has been useful in Ringswitch where we have a lot of orphaned connections, as it limits the number of connections we have open.
245
- # ActiveRecord only calls reap if there are no more connections available in the pool, i.e. if all connections are in use (and potentially orphaned).
246
- def checkout(checkout_timeout = @checkout_timeout)
247
- begin
248
- reap_connections
249
- rescue => ex
250
- ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex}")
251
- end
252
- super
253
- end
254
-
255
- # Invoca Patch - Only used in our #checkout patch above. The main difference this method has with #reap is that we don't call #steal! on the orphaned connections first.
256
- # This may be risky for race conditions but potentially runs faster than the #reap method?
257
- # We should look to replace this with the standard #reap method in the future.
258
66
  def reap_connections
259
67
  cached_connections.values.each do |connection|
260
68
  unless connection.owner.alive?
@@ -263,14 +71,17 @@ module FiberedMysql2
263
71
  end
264
72
  end
265
73
 
266
- # Invoca Patch - Helper method.
267
- def cached_connections
268
- @thread_cached_conns
74
+ private
75
+
76
+ #--
77
+ # This hook-in method allows for easier monkey-patching fixes needed by
78
+ # JRuby users that use Fibers.
79
+ def connection_cache_key(fiber)
80
+ fiber
269
81
  end
270
82
 
271
- # Invoca Patch - Helper method
272
- def current_connection_id
273
- connection_cache_key(current_thread)
83
+ def current_thread
84
+ AsyncTask.current_or_none
274
85
  end
275
86
  end
276
87
  end
@@ -6,17 +6,23 @@ module FiberedMysql2
6
6
  module FiberedMysql2ConnectionFactory
7
7
  def fibered_mysql2_connection(raw_config)
8
8
  config = raw_config.symbolize_keys
9
- config[:flags] ||= 0
10
9
 
11
- if config[:flags].kind_of? Array
12
- config[:flags].push "FOUND_ROWS"
13
- else
14
- config[:flags] |= Mysql2::Client::FOUND_ROWS
15
- end
16
10
  config[:username] = 'root' if config[:username].nil?
11
+ config[:flags] = Mysql2::Client::FOUND_ROWS if Mysql2::Client.const_defined?(:FOUND_ROWS)
17
12
 
18
- client = FiberedMysql2Adapter.new_client(config)
19
- FiberedMysql2Adapter.new(client, logger, nil, config)
13
+ client =
14
+ begin
15
+ Mysql2::Client.new(config)
16
+ rescue Mysql2::Error => error
17
+ if error.message.include?("Unknown database")
18
+ raise ActiveRecord::NoDatabaseError.new(error.message)
19
+ else
20
+ raise
21
+ end
22
+ end
23
+
24
+ options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0]
25
+ FiberedMysql2Adapter.new(client, logger, options, config)
20
26
  end
21
27
  end
22
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiberedMysql2
4
- VERSION = "0.4.0"
4
+ VERSION = "1.0.0.colin.1"
5
5
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'async'
3
4
  require 'fibered_mysql2/version'
4
5
  require_relative '../lib/active_record/connection_adapters/fibered_mysql2_adapter'
5
6
  require 'fibered_mysql2/fibered_database_connection_pool'
6
7
  require 'fibered_mysql2/fibered_mutex_with_waiter_priority'
7
8
  require 'fibered_mysql2/fibered_mysql2_connection_factory'
8
- require_relative 'fibered_mysql2/hash_config_override'
9
9
 
10
10
  module FiberedMysql2
11
11
  class Error < StandardError; end
metadata CHANGED
@@ -1,49 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fibered_mysql2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0.colin.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-21 00:00:00.000000000 Z
11
+ date: 2023-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: em-synchrony
14
+ name: async
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '7.0'
33
+ version: '5.2'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '7.2'
36
+ version: '7'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '7.0'
43
+ version: '5.2'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '7.2'
46
+ version: '7'
47
47
  description:
48
48
  email:
49
49
  - development@invoca.com
@@ -51,6 +51,7 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
+ - ".github/CODEOWNERS"
54
55
  - ".github/workflows/build.yml"
55
56
  - ".github/workflows/release.yml"
56
57
  - ".gitignore"
@@ -65,15 +66,14 @@ files:
65
66
  - bin/console
66
67
  - bin/setup
67
68
  - fibered_mysql2.gemspec
68
- - gemfiles/.bundle/config
69
- - gemfiles/rails_7_0.gemfile
70
- - gemfiles/rails_7_1.gemfile
69
+ - gemfiles/rails_5.gemfile
70
+ - gemfiles/rails_6.gemfile
71
71
  - lib/active_record/connection_adapters/fibered_mysql2_adapter.rb
72
72
  - lib/fibered_mysql2.rb
73
+ - lib/fibered_mysql2/async_task.rb
73
74
  - lib/fibered_mysql2/fibered_database_connection_pool.rb
74
75
  - lib/fibered_mysql2/fibered_mutex_with_waiter_priority.rb
75
76
  - lib/fibered_mysql2/fibered_mysql2_connection_factory.rb
76
- - lib/fibered_mysql2/hash_config_override.rb
77
77
  - lib/fibered_mysql2/version.rb
78
78
  homepage: https://github.com/Invoca/fibered_mysql2
79
79
  licenses: []
@@ -91,11 +91,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - ">"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 1.3.1
97
97
  requirements: []
98
- rubygems_version: 3.3.27
98
+ rubygems_version: 3.4.6
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: An adapter for fibered mysql2
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_RETRY: "1"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "appraisal-matrix"
7
- gem "mysql2", "~> 0.5"
8
- gem "nokogiri"
9
- gem "pry"
10
- gem "pry-byebug"
11
- gem "rake"
12
- gem "rspec", "< 3.13"
13
- gem "rails", "~> 7.0.0"
14
-
15
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "appraisal-matrix"
7
- gem "mysql2", "~> 0.5"
8
- gem "nokogiri"
9
- gem "pry"
10
- gem "pry-byebug"
11
- gem "rake"
12
- gem "rspec", "< 3.13"
13
- gem "rails", "~> 7.1.0"
14
-
15
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_record/database_configurations/hash_config"
4
-
5
- module FiberedMysql2
6
- module HashConfigOverride
7
- # Override the reaping_frequency method to return nil so that the connection pool does not reap connections when in fibered mode.
8
- def reaping_frequency
9
- nil
10
- end
11
- end
12
- end
13
-
14
- if ActiveRecord.gem_version >= "6.1"
15
- ActiveRecord::DatabaseConfigurations::HashConfig.prepend(FiberedMysql2::HashConfigOverride)
16
- end