fibered_mysql2 1.0.0.colin.1 → 1.0.0.colin.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +1 -2
- data/Appraisals +0 -4
- data/Gemfile.lock +113 -103
- data/README.md +5 -4
- data/bin/console +1 -0
- data/fibered_mysql2.gemspec +1 -1
- data/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb +22 -26
- data/lib/fibered_mysql2/fibered_database_connection_pool.rb +5 -12
- data/lib/fibered_mysql2/version.rb +1 -1
- data/lib/fibered_mysql2.rb +4 -9
- metadata +4 -7
- data/gemfiles/rails_5.gemfile +0 -15
- data/lib/fibered_mysql2/async_task.rb +0 -18
- data/lib/fibered_mysql2/fibered_mutex_with_waiter_priority.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1edbb420eedd78ecab2ae0fef48554d968f01e44c791430262f55b43c280dea0
|
4
|
+
data.tar.gz: 676673438f5078176bfbd836d6e34d79283a1aa8874cbd32563266dbf163a5b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6de1e7d5bd5afe99bb1104d772dcef36bf5414d58e57b069bf2883e506c1a5f78551a429b4ee3098321373bee5ff83ee2a200ba3477ebde9bd15d26cd78fa4f
|
7
|
+
data.tar.gz: e506a05e2ffd01f2c0f7380a9fd644735aceb9843f43f683b1972533f5c37d783ef4aa2b8417aa9e25ef548c03bc837fec7aeb9b16a0e000d6683ab6619d3bf7
|
data/.github/workflows/build.yml
CHANGED
data/Appraisals
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fibered_mysql2 (1.0.0.colin.
|
4
|
+
fibered_mysql2 (1.0.0.colin.3)
|
5
5
|
async
|
6
|
-
rails (>=
|
6
|
+
rails (>= 6, < 7)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (6.0.
|
12
|
-
actionpack (= 6.0.
|
11
|
+
actioncable (6.0.6.1)
|
12
|
+
actionpack (= 6.0.6.1)
|
13
13
|
nio4r (~> 2.0)
|
14
14
|
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (6.0.
|
16
|
-
actionpack (= 6.0.
|
17
|
-
activejob (= 6.0.
|
18
|
-
activerecord (= 6.0.
|
19
|
-
activestorage (= 6.0.
|
20
|
-
activesupport (= 6.0.
|
15
|
+
actionmailbox (6.0.6.1)
|
16
|
+
actionpack (= 6.0.6.1)
|
17
|
+
activejob (= 6.0.6.1)
|
18
|
+
activerecord (= 6.0.6.1)
|
19
|
+
activestorage (= 6.0.6.1)
|
20
|
+
activesupport (= 6.0.6.1)
|
21
21
|
mail (>= 2.7.1)
|
22
|
-
actionmailer (6.0.
|
23
|
-
actionpack (= 6.0.
|
24
|
-
actionview (= 6.0.
|
25
|
-
activejob (= 6.0.
|
22
|
+
actionmailer (6.0.6.1)
|
23
|
+
actionpack (= 6.0.6.1)
|
24
|
+
actionview (= 6.0.6.1)
|
25
|
+
activejob (= 6.0.6.1)
|
26
26
|
mail (~> 2.5, >= 2.5.4)
|
27
27
|
rails-dom-testing (~> 2.0)
|
28
|
-
actionpack (6.0.
|
29
|
-
actionview (= 6.0.
|
30
|
-
activesupport (= 6.0.
|
28
|
+
actionpack (6.0.6.1)
|
29
|
+
actionview (= 6.0.6.1)
|
30
|
+
activesupport (= 6.0.6.1)
|
31
31
|
rack (~> 2.0, >= 2.0.8)
|
32
32
|
rack-test (>= 0.6.3)
|
33
33
|
rails-dom-testing (~> 2.0)
|
34
34
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
-
actiontext (6.0.
|
36
|
-
actionpack (= 6.0.
|
37
|
-
activerecord (= 6.0.
|
38
|
-
activestorage (= 6.0.
|
39
|
-
activesupport (= 6.0.
|
35
|
+
actiontext (6.0.6.1)
|
36
|
+
actionpack (= 6.0.6.1)
|
37
|
+
activerecord (= 6.0.6.1)
|
38
|
+
activestorage (= 6.0.6.1)
|
39
|
+
activesupport (= 6.0.6.1)
|
40
40
|
nokogiri (>= 1.8.5)
|
41
|
-
actionview (6.0.
|
42
|
-
activesupport (= 6.0.
|
41
|
+
actionview (6.0.6.1)
|
42
|
+
activesupport (= 6.0.6.1)
|
43
43
|
builder (~> 3.1)
|
44
44
|
erubi (~> 1.4)
|
45
45
|
rails-dom-testing (~> 2.0)
|
46
46
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
-
activejob (6.0.
|
48
|
-
activesupport (= 6.0.
|
47
|
+
activejob (6.0.6.1)
|
48
|
+
activesupport (= 6.0.6.1)
|
49
49
|
globalid (>= 0.3.6)
|
50
|
-
activemodel (6.0.
|
51
|
-
activesupport (= 6.0.
|
52
|
-
activerecord (6.0.
|
53
|
-
activemodel (= 6.0.
|
54
|
-
activesupport (= 6.0.
|
55
|
-
activestorage (6.0.
|
56
|
-
actionpack (= 6.0.
|
57
|
-
activejob (= 6.0.
|
58
|
-
activerecord (= 6.0.
|
59
|
-
marcel (~> 0
|
60
|
-
activesupport (6.0.
|
50
|
+
activemodel (6.0.6.1)
|
51
|
+
activesupport (= 6.0.6.1)
|
52
|
+
activerecord (6.0.6.1)
|
53
|
+
activemodel (= 6.0.6.1)
|
54
|
+
activesupport (= 6.0.6.1)
|
55
|
+
activestorage (6.0.6.1)
|
56
|
+
actionpack (= 6.0.6.1)
|
57
|
+
activejob (= 6.0.6.1)
|
58
|
+
activerecord (= 6.0.6.1)
|
59
|
+
marcel (~> 1.0)
|
60
|
+
activesupport (6.0.6.1)
|
61
61
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
62
62
|
i18n (>= 0.7, < 2)
|
63
63
|
minitest (~> 5.1)
|
64
64
|
tzinfo (~> 1.1)
|
65
65
|
zeitwerk (~> 2.2, >= 2.2.2)
|
66
|
-
appraisal (2.4.
|
66
|
+
appraisal (2.4.1)
|
67
67
|
bundler
|
68
68
|
rake
|
69
69
|
thor (>= 0.14.0)
|
@@ -74,7 +74,7 @@ GEM
|
|
74
74
|
builder (3.2.4)
|
75
75
|
byebug (11.1.3)
|
76
76
|
coderay (1.1.3)
|
77
|
-
concurrent-ruby (1.
|
77
|
+
concurrent-ruby (1.2.2)
|
78
78
|
console (1.16.2)
|
79
79
|
fiber-local
|
80
80
|
coveralls (0.8.23)
|
@@ -84,111 +84,121 @@ GEM
|
|
84
84
|
thor (>= 0.19.4, < 2.0)
|
85
85
|
tins (~> 1.6)
|
86
86
|
crass (1.0.6)
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
date (3.3.3)
|
88
|
+
diff-lcs (1.5.0)
|
89
|
+
docile (1.4.0)
|
90
|
+
erubi (1.12.0)
|
90
91
|
fiber-local (1.0.0)
|
91
|
-
globalid (
|
92
|
-
activesupport (>=
|
93
|
-
i18n (1.
|
92
|
+
globalid (1.1.0)
|
93
|
+
activesupport (>= 5.0)
|
94
|
+
i18n (1.13.0)
|
94
95
|
concurrent-ruby (~> 1.0)
|
95
96
|
io-event (1.2.2)
|
96
|
-
json (2.3
|
97
|
-
loofah (2.
|
97
|
+
json (2.6.3)
|
98
|
+
loofah (2.21.3)
|
98
99
|
crass (~> 1.0.2)
|
99
|
-
nokogiri (>= 1.
|
100
|
-
mail (2.
|
100
|
+
nokogiri (>= 1.12.0)
|
101
|
+
mail (2.8.1)
|
101
102
|
mini_mime (>= 0.1.1)
|
102
|
-
|
103
|
-
|
103
|
+
net-imap
|
104
|
+
net-pop
|
105
|
+
net-smtp
|
106
|
+
marcel (1.0.2)
|
104
107
|
method_source (1.0.0)
|
105
|
-
|
106
|
-
nokogiri (~> 1)
|
107
|
-
rake
|
108
|
-
mini_mime (1.0.2)
|
108
|
+
mini_mime (1.1.2)
|
109
109
|
mini_portile2 (2.6.1)
|
110
|
-
minitest (5.
|
110
|
+
minitest (5.18.0)
|
111
111
|
mysql2 (0.5.5)
|
112
|
-
|
112
|
+
net-imap (0.3.4)
|
113
|
+
date
|
114
|
+
net-protocol
|
115
|
+
net-pop (0.1.2)
|
116
|
+
net-protocol
|
117
|
+
net-protocol (0.2.1)
|
118
|
+
timeout
|
119
|
+
net-smtp (0.3.3)
|
120
|
+
net-protocol
|
121
|
+
nio4r (2.5.9)
|
113
122
|
nokogiri (1.12.5)
|
114
123
|
mini_portile2 (~> 2.6.1)
|
115
124
|
racc (~> 1.4)
|
116
|
-
pry (0.
|
125
|
+
pry (0.14.2)
|
117
126
|
coderay (~> 1.1)
|
118
127
|
method_source (~> 1.0)
|
119
|
-
pry-byebug (3.
|
128
|
+
pry-byebug (3.10.1)
|
120
129
|
byebug (~> 11.0)
|
121
|
-
pry (
|
122
|
-
racc (1.6.
|
123
|
-
rack (2.2.
|
124
|
-
rack-test (
|
125
|
-
rack (>= 1.
|
126
|
-
rails (6.0.
|
127
|
-
actioncable (= 6.0.
|
128
|
-
actionmailbox (= 6.0.
|
129
|
-
actionmailer (= 6.0.
|
130
|
-
actionpack (= 6.0.
|
131
|
-
actiontext (= 6.0.
|
132
|
-
actionview (= 6.0.
|
133
|
-
activejob (= 6.0.
|
134
|
-
activemodel (= 6.0.
|
135
|
-
activerecord (= 6.0.
|
136
|
-
activestorage (= 6.0.
|
137
|
-
activesupport (= 6.0.
|
130
|
+
pry (>= 0.13, < 0.15)
|
131
|
+
racc (1.6.2)
|
132
|
+
rack (2.2.7)
|
133
|
+
rack-test (2.1.0)
|
134
|
+
rack (>= 1.3)
|
135
|
+
rails (6.0.6.1)
|
136
|
+
actioncable (= 6.0.6.1)
|
137
|
+
actionmailbox (= 6.0.6.1)
|
138
|
+
actionmailer (= 6.0.6.1)
|
139
|
+
actionpack (= 6.0.6.1)
|
140
|
+
actiontext (= 6.0.6.1)
|
141
|
+
actionview (= 6.0.6.1)
|
142
|
+
activejob (= 6.0.6.1)
|
143
|
+
activemodel (= 6.0.6.1)
|
144
|
+
activerecord (= 6.0.6.1)
|
145
|
+
activestorage (= 6.0.6.1)
|
146
|
+
activesupport (= 6.0.6.1)
|
138
147
|
bundler (>= 1.3.0)
|
139
|
-
railties (= 6.0.
|
148
|
+
railties (= 6.0.6.1)
|
140
149
|
sprockets-rails (>= 2.0.0)
|
141
150
|
rails-dom-testing (2.0.3)
|
142
151
|
activesupport (>= 4.2.0)
|
143
152
|
nokogiri (>= 1.6)
|
144
|
-
rails-html-sanitizer (1.
|
145
|
-
loofah (~> 2.
|
146
|
-
railties (6.0.
|
147
|
-
actionpack (= 6.0.
|
148
|
-
activesupport (= 6.0.
|
153
|
+
rails-html-sanitizer (1.5.0)
|
154
|
+
loofah (~> 2.19, >= 2.19.1)
|
155
|
+
railties (6.0.6.1)
|
156
|
+
actionpack (= 6.0.6.1)
|
157
|
+
activesupport (= 6.0.6.1)
|
149
158
|
method_source
|
150
159
|
rake (>= 0.8.7)
|
151
160
|
thor (>= 0.20.3, < 2.0)
|
152
161
|
rake (13.0.6)
|
153
|
-
rspec (3.
|
154
|
-
rspec-core (~> 3.
|
155
|
-
rspec-expectations (~> 3.
|
156
|
-
rspec-mocks (~> 3.
|
157
|
-
rspec-core (3.
|
158
|
-
rspec-support (~> 3.
|
159
|
-
rspec-expectations (3.
|
162
|
+
rspec (3.12.0)
|
163
|
+
rspec-core (~> 3.12.0)
|
164
|
+
rspec-expectations (~> 3.12.0)
|
165
|
+
rspec-mocks (~> 3.12.0)
|
166
|
+
rspec-core (3.12.2)
|
167
|
+
rspec-support (~> 3.12.0)
|
168
|
+
rspec-expectations (3.12.3)
|
160
169
|
diff-lcs (>= 1.2.0, < 2.0)
|
161
|
-
rspec-support (~> 3.
|
162
|
-
rspec-mocks (3.
|
170
|
+
rspec-support (~> 3.12.0)
|
171
|
+
rspec-mocks (3.12.5)
|
163
172
|
diff-lcs (>= 1.2.0, < 2.0)
|
164
|
-
rspec-support (~> 3.
|
165
|
-
rspec-support (3.
|
173
|
+
rspec-support (~> 3.12.0)
|
174
|
+
rspec-support (3.12.0)
|
166
175
|
simplecov (0.16.1)
|
167
176
|
docile (~> 1.1)
|
168
177
|
json (>= 1.8, < 3)
|
169
178
|
simplecov-html (~> 0.10.0)
|
170
179
|
simplecov-html (0.10.2)
|
171
|
-
sprockets (4.0
|
180
|
+
sprockets (4.2.0)
|
172
181
|
concurrent-ruby (~> 1.0)
|
173
|
-
rack (
|
174
|
-
sprockets-rails (3.
|
175
|
-
actionpack (>=
|
176
|
-
activesupport (>=
|
182
|
+
rack (>= 2.2.4, < 4)
|
183
|
+
sprockets-rails (3.4.2)
|
184
|
+
actionpack (>= 5.2)
|
185
|
+
activesupport (>= 5.2)
|
177
186
|
sprockets (>= 3.0.0)
|
178
187
|
sync (0.5.0)
|
179
188
|
term-ansicolor (1.7.1)
|
180
189
|
tins (~> 1.0)
|
181
|
-
thor (1.
|
190
|
+
thor (1.2.2)
|
182
191
|
thread_safe (0.3.6)
|
192
|
+
timeout (0.3.2)
|
183
193
|
timers (4.3.5)
|
184
|
-
tins (1.
|
194
|
+
tins (1.32.1)
|
185
195
|
sync
|
186
|
-
tzinfo (1.2.
|
196
|
+
tzinfo (1.2.11)
|
187
197
|
thread_safe (~> 0.1)
|
188
|
-
websocket-driver (0.7.
|
198
|
+
websocket-driver (0.7.5)
|
189
199
|
websocket-extensions (>= 0.1.0)
|
190
200
|
websocket-extensions (0.1.5)
|
191
|
-
zeitwerk (2.
|
201
|
+
zeitwerk (2.6.8)
|
192
202
|
|
193
203
|
PLATFORMS
|
194
204
|
ruby
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
# FiberedMysql2
|
4
4
|
|
5
|
-
FiberedMysql2 adds Fiber support to `ActiveRecord::ConnectionAdapters::
|
5
|
+
FiberedMysql2 adds Fiber support to `ActiveRecord::ConnectionAdapters::Mysql2Adapter` for Rails 6.
|
6
|
+
This is a stop-gap until Rails 7, which adds `isolation_level: :fiber` to `ActiveRecord`.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -21,15 +22,15 @@ Or install it yourself as:
|
|
21
22
|
$ gem install fibered_mysql2
|
22
23
|
|
23
24
|
## Support
|
24
|
-
Tested with Rails
|
25
|
+
Tested with Rails 6.0, Ruby 3, and Async.
|
25
26
|
|
26
27
|
## Usage
|
27
28
|
|
28
|
-
Behaves the same as `ActiveRecord::ConnectionAdapters::
|
29
|
+
Behaves the same as `ActiveRecord::ConnectionAdapters::Mysql2Adapter` but with using Fibers rather than Threads for tracking ownership when leasing/expiring connections.
|
29
30
|
```ruby
|
30
31
|
connection = FiberedMysql2::FiberedMysql2Adapter.new(client, logger, options, config)
|
31
32
|
connection.lease
|
32
|
-
connection.expire
|
33
|
+
connection.expire
|
33
34
|
```
|
34
35
|
|
35
36
|
## Development
|
data/bin/console
CHANGED
data/fibered_mysql2.gemspec
CHANGED
@@ -3,34 +3,33 @@
|
|
3
3
|
require 'active_model'
|
4
4
|
require 'active_record/errors'
|
5
5
|
require 'active_record/connection_adapters/mysql2_adapter'
|
6
|
-
require_relative '../../fibered_mysql2/async_task'
|
7
6
|
|
8
7
|
module FiberedMysql2
|
9
8
|
module FiberedMysql2Adapter_6
|
10
9
|
def lease
|
11
|
-
if (
|
10
|
+
if (of = owner_fiber)
|
12
11
|
msg = +"Cannot lease connection; "
|
13
|
-
if
|
14
|
-
msg << "it is already leased by the current
|
12
|
+
if of == Fiber.current
|
13
|
+
msg << "it is already leased by the current Fiber."
|
15
14
|
else
|
16
|
-
msg << "it is already in use by a different
|
17
|
-
"Current
|
15
|
+
msg << "it is already in use by a different Fiber: #{of}. " \
|
16
|
+
"Current Fiber: #{Fiber.current}."
|
18
17
|
end
|
19
18
|
raise ::ActiveRecord::ActiveRecordError, msg
|
20
19
|
end
|
21
20
|
|
22
|
-
@owner =
|
21
|
+
@owner = Fiber.current
|
23
22
|
end
|
24
23
|
|
25
24
|
def expire
|
26
|
-
if (
|
27
|
-
# Because we are actively releasing connections from dead
|
28
|
-
# to enforce that we're expiring the current
|
25
|
+
if (of = owner_fiber)
|
26
|
+
# Because we are actively releasing connections from dead fibers, we only want
|
27
|
+
# to enforce that we're expiring the current fiber's connection, iff the owner
|
29
28
|
# of the connection is still alive.
|
30
|
-
if
|
29
|
+
if of.alive? && of != Fiber.current
|
31
30
|
raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection; " \
|
32
|
-
"it is owned by a different
|
33
|
-
"Current
|
31
|
+
"it is owned by a different Fiber: #{of}. " \
|
32
|
+
"Current Fiber: #{Fiber.current}."
|
34
33
|
end
|
35
34
|
|
36
35
|
@idle_since = ::Concurrent.monotonic_time
|
@@ -41,11 +40,11 @@ module FiberedMysql2
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def steal!
|
44
|
-
if (
|
45
|
-
if
|
46
|
-
pool.send :remove_connection_from_thread_cache, self,
|
43
|
+
if (of = owner_fiber)
|
44
|
+
if of != Fiber.current
|
45
|
+
pool.send :remove_connection_from_thread_cache, self, of
|
47
46
|
|
48
|
-
@owner =
|
47
|
+
@owner = Fiber.current
|
49
48
|
end
|
50
49
|
else
|
51
50
|
raise ::ActiveRecord::ActiveRecordError, "Cannot steal connection; it is not currently leased."
|
@@ -54,20 +53,17 @@ module FiberedMysql2
|
|
54
53
|
|
55
54
|
private
|
56
55
|
|
57
|
-
def
|
58
|
-
@owner.nil? || @owner
|
59
|
-
raise "@owner must be
|
56
|
+
def owner_fiber
|
57
|
+
@owner.nil? || @owner.is_a?(Fiber) or
|
58
|
+
raise "@owner must be a Fiber! Found #{@owner.inspect}"
|
60
59
|
@owner
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
64
63
|
class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
else
|
69
|
-
raise ArgumentError, "unexpected Rails version #{Rails::VERSION::MAJOR}"
|
70
|
-
end
|
64
|
+
ActiveRecord::VERSION::MAJOR == 6 or raise ArgumentError, "unexpected Rails version #{ActiveRecord::VERSION::MAJOR}"
|
65
|
+
|
66
|
+
include FiberedMysql2Adapter_6
|
71
67
|
|
72
68
|
def initialize(*args)
|
73
69
|
super
|
@@ -1,17 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# This class behaves the same as ActiveRecord's ConnectionPool, but synchronizes with
|
4
|
-
|
5
|
-
# Note - trace statements have been commented out. This is useful trace but we do not want it on by default.
|
6
|
-
# When we have configurable logging we can put this back and have it off by default.
|
3
|
+
# This class behaves the same as ActiveRecord's ConnectionPool, but synchronizes with fibers rather than threads.
|
7
4
|
|
8
5
|
module FiberedMysql2
|
9
6
|
module FiberedDatabaseConnectionPool
|
10
|
-
|
11
|
-
when 6
|
12
|
-
else
|
13
|
-
raise ArgumentError, "unexpected Rails version #{Rails::VERSION::MAJOR}"
|
14
|
-
end
|
7
|
+
ActiveRecord::VERSION::MAJOR == 6 or raise ArgumentError, "unexpected Rails version #{ActiveRecord::VERSION::MAJOR}"
|
15
8
|
|
16
9
|
def cached_connections
|
17
10
|
@thread_cached_conns
|
@@ -30,8 +23,8 @@ module FiberedMysql2
|
|
30
23
|
super
|
31
24
|
end
|
32
25
|
|
33
|
-
def release_connection(
|
34
|
-
if (conn = @thread_cached_conns.delete(connection_cache_key(
|
26
|
+
def release_connection(owner = Fiber.current)
|
27
|
+
if (conn = @thread_cached_conns.delete(connection_cache_key(owner)))
|
35
28
|
checkin(conn)
|
36
29
|
end
|
37
30
|
end
|
@@ -81,7 +74,7 @@ module FiberedMysql2
|
|
81
74
|
end
|
82
75
|
|
83
76
|
def current_thread
|
84
|
-
|
77
|
+
Fiber.current
|
85
78
|
end
|
86
79
|
end
|
87
80
|
end
|
data/lib/fibered_mysql2.rb
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'async'
|
4
|
-
require 'fibered_mysql2/version'
|
5
|
-
require_relative '../lib/active_record/connection_adapters/fibered_mysql2_adapter'
|
6
|
-
require 'fibered_mysql2/fibered_database_connection_pool'
|
7
|
-
require 'fibered_mysql2/fibered_mutex_with_waiter_priority'
|
8
|
-
require 'fibered_mysql2/fibered_mysql2_connection_factory'
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
require_relative 'active_record/connection_adapters/fibered_mysql2_adapter'
|
6
|
+
require_relative 'fibered_mysql2/fibered_database_connection_pool'
|
7
|
+
require_relative 'fibered_mysql2/fibered_mysql2_connection_factory'
|
8
|
+
require_relative 'fibered_mysql2/version'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fibered_mysql2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.colin.
|
4
|
+
version: 1.0.0.colin.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca Development
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '6'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '7'
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '6'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '7'
|
@@ -66,13 +66,10 @@ files:
|
|
66
66
|
- bin/console
|
67
67
|
- bin/setup
|
68
68
|
- fibered_mysql2.gemspec
|
69
|
-
- gemfiles/rails_5.gemfile
|
70
69
|
- gemfiles/rails_6.gemfile
|
71
70
|
- lib/active_record/connection_adapters/fibered_mysql2_adapter.rb
|
72
71
|
- lib/fibered_mysql2.rb
|
73
|
-
- lib/fibered_mysql2/async_task.rb
|
74
72
|
- lib/fibered_mysql2/fibered_database_connection_pool.rb
|
75
|
-
- lib/fibered_mysql2/fibered_mutex_with_waiter_priority.rb
|
76
73
|
- lib/fibered_mysql2/fibered_mysql2_connection_factory.rb
|
77
74
|
- lib/fibered_mysql2/version.rb
|
78
75
|
homepage: https://github.com/Invoca/fibered_mysql2
|
data/gemfiles/rails_5.gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
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: "../"
|
@@ -1,18 +0,0 @@
|
|
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,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FiberedMysql2
|
4
|
-
module FiberedMutexWithWaiterPriority
|
5
|
-
# Note: @waiters is a bit confusing because the first waiter is actually the current fiber that has it locked;
|
6
|
-
# the _rest_ of @waiters are the actual waiters
|
7
|
-
def sleep(timeout = nil)
|
8
|
-
unlock
|
9
|
-
beg = Time.now
|
10
|
-
current = Fiber.current
|
11
|
-
@slept[current] = true
|
12
|
-
if timeout
|
13
|
-
timer = EM.add_timer(timeout) do
|
14
|
-
_wakeup(current)
|
15
|
-
end
|
16
|
-
Fiber.yield
|
17
|
-
EM.cancel_timer(timer) # if we resumed not via timer
|
18
|
-
else
|
19
|
-
Fiber.yield
|
20
|
-
end
|
21
|
-
@slept.delete(current)
|
22
|
-
yield if block_given?
|
23
|
-
|
24
|
-
# Invoca patch: inline lock that puts us at the front of the mutex @waiters queue instead of the back
|
25
|
-
# ==========================
|
26
|
-
@waiters.unshift(current)
|
27
|
-
Fiber.yield if @waiters.size > 1
|
28
|
-
# ==========================
|
29
|
-
|
30
|
-
Time.now - beg
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|