fibered_mysql2 0.1.0.pre.2
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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +12 -0
- data/Appraisals +13 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +198 -0
- data/README.md +43 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fibered_mysql2.gemspec +32 -0
- data/gemfiles/rails_4.gemfile +15 -0
- data/gemfiles/rails_5.gemfile +15 -0
- data/gemfiles/rails_6.gemfile +15 -0
- data/lib/fibered_mysql2.rb +8 -0
- data/lib/fibered_mysql2/fibered_mysql2_adapter.rb +66 -0
- data/lib/fibered_mysql2/version.rb +5 -0
- metadata +96 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 20d3f46c3c9b81ecdce87f118026e95bfe623322dc69deddd6beec758d550350
|
|
4
|
+
data.tar.gz: 4193bb8362385556eeb6b966814ec5809d0e1a68c9a09ebd5e235165b298db5c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8ff1891831752d602a3a56dec657d7b8b6111d7257e3c890c33acddd95a4b0651a5309d44aae7ac21184b0b614e58f4c70fe40f58f3eb62eaab8fcd66e52e14a
|
|
7
|
+
data.tar.gz: c3cf276f8e0eaf7a99626c6aa5e0d34993d9763fd382782c7fb73605fa5211a45508324f442e6eb57f7a25896db2e44bf1102e0e99f6a0007b5dd02b6910a23c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# CHANGELOG for `fibered_mysql2`
|
|
2
|
+
|
|
3
|
+
Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
|
+
|
|
5
|
+
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - Unreleased
|
|
8
|
+
### Added
|
|
9
|
+
- An adapter for Rails 4, 5, and 6.
|
|
10
|
+
- Appraisals for Rails 4, 5, and 6.
|
|
11
|
+
- TravisCI unit test pipeline.
|
|
12
|
+
- Coverage reports via Coveralls.
|
|
13
|
+
|
|
14
|
+
[0.1.0]: https://github.com/Invoca/fibered_mysql2/tree/v0.1.0
|
data/Gemfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in fibered_mysql2.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
gem 'appraisal'
|
|
9
|
+
gem 'bundler', '~> 1.8'
|
|
10
|
+
gem 'coveralls', require: false
|
|
11
|
+
gem 'mysql2', '0.4.5'
|
|
12
|
+
gem 'pry', '~> 0.13'
|
|
13
|
+
gem 'pry-byebug', '~> 3.9'
|
|
14
|
+
gem 'rake', '~> 10.0'
|
|
15
|
+
gem 'rspec', '~> 3.0'
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
fibered_mysql2 (0.1.0.pre.2)
|
|
5
|
+
em-synchrony (~> 1.0)
|
|
6
|
+
rails (>= 4.2, < 7)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
actioncable (6.0.3.3)
|
|
12
|
+
actionpack (= 6.0.3.3)
|
|
13
|
+
nio4r (~> 2.0)
|
|
14
|
+
websocket-driver (>= 0.6.1)
|
|
15
|
+
actionmailbox (6.0.3.3)
|
|
16
|
+
actionpack (= 6.0.3.3)
|
|
17
|
+
activejob (= 6.0.3.3)
|
|
18
|
+
activerecord (= 6.0.3.3)
|
|
19
|
+
activestorage (= 6.0.3.3)
|
|
20
|
+
activesupport (= 6.0.3.3)
|
|
21
|
+
mail (>= 2.7.1)
|
|
22
|
+
actionmailer (6.0.3.3)
|
|
23
|
+
actionpack (= 6.0.3.3)
|
|
24
|
+
actionview (= 6.0.3.3)
|
|
25
|
+
activejob (= 6.0.3.3)
|
|
26
|
+
mail (~> 2.5, >= 2.5.4)
|
|
27
|
+
rails-dom-testing (~> 2.0)
|
|
28
|
+
actionpack (6.0.3.3)
|
|
29
|
+
actionview (= 6.0.3.3)
|
|
30
|
+
activesupport (= 6.0.3.3)
|
|
31
|
+
rack (~> 2.0, >= 2.0.8)
|
|
32
|
+
rack-test (>= 0.6.3)
|
|
33
|
+
rails-dom-testing (~> 2.0)
|
|
34
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
35
|
+
actiontext (6.0.3.3)
|
|
36
|
+
actionpack (= 6.0.3.3)
|
|
37
|
+
activerecord (= 6.0.3.3)
|
|
38
|
+
activestorage (= 6.0.3.3)
|
|
39
|
+
activesupport (= 6.0.3.3)
|
|
40
|
+
nokogiri (>= 1.8.5)
|
|
41
|
+
actionview (6.0.3.3)
|
|
42
|
+
activesupport (= 6.0.3.3)
|
|
43
|
+
builder (~> 3.1)
|
|
44
|
+
erubi (~> 1.4)
|
|
45
|
+
rails-dom-testing (~> 2.0)
|
|
46
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
47
|
+
activejob (6.0.3.3)
|
|
48
|
+
activesupport (= 6.0.3.3)
|
|
49
|
+
globalid (>= 0.3.6)
|
|
50
|
+
activemodel (6.0.3.3)
|
|
51
|
+
activesupport (= 6.0.3.3)
|
|
52
|
+
activerecord (6.0.3.3)
|
|
53
|
+
activemodel (= 6.0.3.3)
|
|
54
|
+
activesupport (= 6.0.3.3)
|
|
55
|
+
activestorage (6.0.3.3)
|
|
56
|
+
actionpack (= 6.0.3.3)
|
|
57
|
+
activejob (= 6.0.3.3)
|
|
58
|
+
activerecord (= 6.0.3.3)
|
|
59
|
+
marcel (~> 0.3.1)
|
|
60
|
+
activesupport (6.0.3.3)
|
|
61
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
62
|
+
i18n (>= 0.7, < 2)
|
|
63
|
+
minitest (~> 5.1)
|
|
64
|
+
tzinfo (~> 1.1)
|
|
65
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
|
66
|
+
appraisal (2.3.0)
|
|
67
|
+
bundler
|
|
68
|
+
rake
|
|
69
|
+
thor (>= 0.14.0)
|
|
70
|
+
builder (3.2.4)
|
|
71
|
+
byebug (11.1.3)
|
|
72
|
+
coderay (1.1.3)
|
|
73
|
+
concurrent-ruby (1.1.7)
|
|
74
|
+
coveralls (0.8.23)
|
|
75
|
+
json (>= 1.8, < 3)
|
|
76
|
+
simplecov (~> 0.16.1)
|
|
77
|
+
term-ansicolor (~> 1.3)
|
|
78
|
+
thor (>= 0.19.4, < 2.0)
|
|
79
|
+
tins (~> 1.6)
|
|
80
|
+
crass (1.0.6)
|
|
81
|
+
diff-lcs (1.4.4)
|
|
82
|
+
docile (1.3.2)
|
|
83
|
+
em-synchrony (1.0.6)
|
|
84
|
+
eventmachine (>= 1.0.0.beta.1)
|
|
85
|
+
erubi (1.9.0)
|
|
86
|
+
eventmachine (1.2.7)
|
|
87
|
+
globalid (0.4.2)
|
|
88
|
+
activesupport (>= 4.2.0)
|
|
89
|
+
i18n (1.8.5)
|
|
90
|
+
concurrent-ruby (~> 1.0)
|
|
91
|
+
json (2.3.1)
|
|
92
|
+
loofah (2.7.0)
|
|
93
|
+
crass (~> 1.0.2)
|
|
94
|
+
nokogiri (>= 1.5.9)
|
|
95
|
+
mail (2.7.1)
|
|
96
|
+
mini_mime (>= 0.1.1)
|
|
97
|
+
marcel (0.3.3)
|
|
98
|
+
mimemagic (~> 0.3.2)
|
|
99
|
+
method_source (1.0.0)
|
|
100
|
+
mimemagic (0.3.5)
|
|
101
|
+
mini_mime (1.0.2)
|
|
102
|
+
mini_portile2 (2.4.0)
|
|
103
|
+
minitest (5.14.2)
|
|
104
|
+
mysql2 (0.4.5)
|
|
105
|
+
nio4r (2.5.4)
|
|
106
|
+
nokogiri (1.10.10)
|
|
107
|
+
mini_portile2 (~> 2.4.0)
|
|
108
|
+
pry (0.13.1)
|
|
109
|
+
coderay (~> 1.1)
|
|
110
|
+
method_source (~> 1.0)
|
|
111
|
+
pry-byebug (3.9.0)
|
|
112
|
+
byebug (~> 11.0)
|
|
113
|
+
pry (~> 0.13.0)
|
|
114
|
+
rack (2.2.3)
|
|
115
|
+
rack-test (1.1.0)
|
|
116
|
+
rack (>= 1.0, < 3)
|
|
117
|
+
rails (6.0.3.3)
|
|
118
|
+
actioncable (= 6.0.3.3)
|
|
119
|
+
actionmailbox (= 6.0.3.3)
|
|
120
|
+
actionmailer (= 6.0.3.3)
|
|
121
|
+
actionpack (= 6.0.3.3)
|
|
122
|
+
actiontext (= 6.0.3.3)
|
|
123
|
+
actionview (= 6.0.3.3)
|
|
124
|
+
activejob (= 6.0.3.3)
|
|
125
|
+
activemodel (= 6.0.3.3)
|
|
126
|
+
activerecord (= 6.0.3.3)
|
|
127
|
+
activestorage (= 6.0.3.3)
|
|
128
|
+
activesupport (= 6.0.3.3)
|
|
129
|
+
bundler (>= 1.3.0)
|
|
130
|
+
railties (= 6.0.3.3)
|
|
131
|
+
sprockets-rails (>= 2.0.0)
|
|
132
|
+
rails-dom-testing (2.0.3)
|
|
133
|
+
activesupport (>= 4.2.0)
|
|
134
|
+
nokogiri (>= 1.6)
|
|
135
|
+
rails-html-sanitizer (1.3.0)
|
|
136
|
+
loofah (~> 2.3)
|
|
137
|
+
railties (6.0.3.3)
|
|
138
|
+
actionpack (= 6.0.3.3)
|
|
139
|
+
activesupport (= 6.0.3.3)
|
|
140
|
+
method_source
|
|
141
|
+
rake (>= 0.8.7)
|
|
142
|
+
thor (>= 0.20.3, < 2.0)
|
|
143
|
+
rake (10.5.0)
|
|
144
|
+
rspec (3.9.0)
|
|
145
|
+
rspec-core (~> 3.9.0)
|
|
146
|
+
rspec-expectations (~> 3.9.0)
|
|
147
|
+
rspec-mocks (~> 3.9.0)
|
|
148
|
+
rspec-core (3.9.3)
|
|
149
|
+
rspec-support (~> 3.9.3)
|
|
150
|
+
rspec-expectations (3.9.2)
|
|
151
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
152
|
+
rspec-support (~> 3.9.0)
|
|
153
|
+
rspec-mocks (3.9.1)
|
|
154
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
155
|
+
rspec-support (~> 3.9.0)
|
|
156
|
+
rspec-support (3.9.3)
|
|
157
|
+
simplecov (0.16.1)
|
|
158
|
+
docile (~> 1.1)
|
|
159
|
+
json (>= 1.8, < 3)
|
|
160
|
+
simplecov-html (~> 0.10.0)
|
|
161
|
+
simplecov-html (0.10.2)
|
|
162
|
+
sprockets (4.0.2)
|
|
163
|
+
concurrent-ruby (~> 1.0)
|
|
164
|
+
rack (> 1, < 3)
|
|
165
|
+
sprockets-rails (3.2.2)
|
|
166
|
+
actionpack (>= 4.0)
|
|
167
|
+
activesupport (>= 4.0)
|
|
168
|
+
sprockets (>= 3.0.0)
|
|
169
|
+
sync (0.5.0)
|
|
170
|
+
term-ansicolor (1.7.1)
|
|
171
|
+
tins (~> 1.0)
|
|
172
|
+
thor (1.0.1)
|
|
173
|
+
thread_safe (0.3.6)
|
|
174
|
+
tins (1.25.0)
|
|
175
|
+
sync
|
|
176
|
+
tzinfo (1.2.7)
|
|
177
|
+
thread_safe (~> 0.1)
|
|
178
|
+
websocket-driver (0.7.3)
|
|
179
|
+
websocket-extensions (>= 0.1.0)
|
|
180
|
+
websocket-extensions (0.1.5)
|
|
181
|
+
zeitwerk (2.4.0)
|
|
182
|
+
|
|
183
|
+
PLATFORMS
|
|
184
|
+
ruby
|
|
185
|
+
|
|
186
|
+
DEPENDENCIES
|
|
187
|
+
appraisal
|
|
188
|
+
bundler (~> 1.8)
|
|
189
|
+
coveralls
|
|
190
|
+
fibered_mysql2!
|
|
191
|
+
mysql2 (= 0.4.5)
|
|
192
|
+
pry (~> 0.13)
|
|
193
|
+
pry-byebug (~> 3.9)
|
|
194
|
+
rake (~> 10.0)
|
|
195
|
+
rspec (~> 3.0)
|
|
196
|
+
|
|
197
|
+
BUNDLED WITH
|
|
198
|
+
1.17.2
|
data/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[](https://coveralls.io/github/Invoca/fibered_mysql2?branch=master)
|
|
2
|
+
|
|
3
|
+
# FiberedMysql2
|
|
4
|
+
|
|
5
|
+
FiberedMysql2 adds Fiber support to `ActiveRecord::ConnectionAdapters::EMMysql2Adapter`
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'fibered_mysql2'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install fibered_mysql2
|
|
22
|
+
|
|
23
|
+
## Support
|
|
24
|
+
Tested with Rails versions 4.2, 5.2, and 6.0.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Behaves the same as `ActiveRecord::ConnectionAdapters::EMMysql2Adapter` but with added Fiber safety while leasing/expiring connections.
|
|
29
|
+
```ruby
|
|
30
|
+
connection = FiberedMysql2::FiberedMysql2Adapter.new(client, logger, options, config)
|
|
31
|
+
connection.lease
|
|
32
|
+
connection.expire // Rails 5+ only
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
38
|
+
|
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
40
|
+
|
|
41
|
+
## Contributing
|
|
42
|
+
|
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/invoca/fibered_mysql2.
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "fibered_mysql2"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require "fibered_mysql2/version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "fibered_mysql2"
|
|
9
|
+
spec.version = FiberedMysql2::VERSION
|
|
10
|
+
spec.authors = ["Octothorp"]
|
|
11
|
+
spec.email = ["octothorp@invoca.com"]
|
|
12
|
+
|
|
13
|
+
spec.summary = "An adapter for fibered mysql2"
|
|
14
|
+
spec.homepage = "https://github.com/Invoca/fibered_mysql2"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_dependency 'em-synchrony', '~> 1.0'
|
|
31
|
+
spec.add_dependency 'rails', '>= 4.2', '< 7'
|
|
32
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "appraisal"
|
|
6
|
+
gem "bundler", "~> 1.8"
|
|
7
|
+
gem "coveralls", require: false
|
|
8
|
+
gem "mysql2", "0.4.5"
|
|
9
|
+
gem "pry", "~> 0.13"
|
|
10
|
+
gem "pry-byebug", "~> 3.9"
|
|
11
|
+
gem "rake", "~> 10.0"
|
|
12
|
+
gem "rspec", "~> 3.0"
|
|
13
|
+
gem "rails", "~> 4.2"
|
|
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 "bundler", "~> 1.8"
|
|
7
|
+
gem "coveralls", require: false
|
|
8
|
+
gem "mysql2", "0.4.5"
|
|
9
|
+
gem "pry", "~> 0.13"
|
|
10
|
+
gem "pry-byebug", "~> 3.9"
|
|
11
|
+
gem "rake", "~> 10.0"
|
|
12
|
+
gem "rspec", "~> 3.0"
|
|
13
|
+
gem "rails", "~> 5.2"
|
|
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 "bundler", "~> 1.8"
|
|
7
|
+
gem "coveralls", require: false
|
|
8
|
+
gem "mysql2", "0.4.5"
|
|
9
|
+
gem "pry", "~> 0.13"
|
|
10
|
+
gem "pry-byebug", "~> 3.9"
|
|
11
|
+
gem "rake", "~> 10.0"
|
|
12
|
+
gem "rspec", "~> 3.0"
|
|
13
|
+
gem "rails", "~> 6.0"
|
|
14
|
+
|
|
15
|
+
gemspec path: "../"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'em-synchrony'
|
|
4
|
+
require 'active_model'
|
|
5
|
+
require 'active_record/errors'
|
|
6
|
+
require 'active_record/connection_adapters/em_mysql2_adapter'
|
|
7
|
+
|
|
8
|
+
module FiberedMysql2
|
|
9
|
+
module FiberedMysql2Adapter_4_2
|
|
10
|
+
def lease
|
|
11
|
+
synchronize do
|
|
12
|
+
unless in_use?
|
|
13
|
+
@owner = Fiber.current
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module FiberedMysql2Adapter_5_2
|
|
20
|
+
def lease
|
|
21
|
+
if in_use?
|
|
22
|
+
msg = "Cannot lease connection, ".dup
|
|
23
|
+
if @owner == Fiber.current
|
|
24
|
+
msg << "it is already leased by the current fiber."
|
|
25
|
+
else
|
|
26
|
+
msg << "it is already in use by a different fiber: #{@owner}. " \
|
|
27
|
+
"Current fiber: #{Fiber.current}."
|
|
28
|
+
end
|
|
29
|
+
raise ::ActiveRecord::ActiveRecordError, msg
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
@owner = Fiber.current
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def expire
|
|
36
|
+
if in_use?
|
|
37
|
+
# Because we are actively releasing connections from dead fibers, we only want
|
|
38
|
+
# to enforce that we're expiring the current fibers connection, iff the owner
|
|
39
|
+
# of the connection is still alive.
|
|
40
|
+
if @owner.alive? && @owner != Fiber.current
|
|
41
|
+
raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, " \
|
|
42
|
+
"it is owned by a different fiber: #{@owner}. " \
|
|
43
|
+
"Current fiber: #{Fiber.current}."
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
@idle_since = ::Concurrent.monotonic_time
|
|
47
|
+
@owner = nil
|
|
48
|
+
else
|
|
49
|
+
raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, it is not currently leased."
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::EMMysql2Adapter
|
|
55
|
+
case ::Rails::VERSION::MAJOR
|
|
56
|
+
when 4
|
|
57
|
+
include FiberedMysql2Adapter_4_2
|
|
58
|
+
when 5, 6
|
|
59
|
+
include FiberedMysql2Adapter_5_2
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def initialize(*args)
|
|
63
|
+
super
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fibered_mysql2
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0.pre.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Octothorp
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: em-synchrony
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rails
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '4.2'
|
|
34
|
+
- - "<"
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '7'
|
|
37
|
+
type: :runtime
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '4.2'
|
|
44
|
+
- - "<"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '7'
|
|
47
|
+
description:
|
|
48
|
+
email:
|
|
49
|
+
- octothorp@invoca.com
|
|
50
|
+
executables: []
|
|
51
|
+
extensions: []
|
|
52
|
+
extra_rdoc_files: []
|
|
53
|
+
files:
|
|
54
|
+
- ".gitignore"
|
|
55
|
+
- ".rspec"
|
|
56
|
+
- ".travis.yml"
|
|
57
|
+
- Appraisals
|
|
58
|
+
- CHANGELOG.md
|
|
59
|
+
- Gemfile
|
|
60
|
+
- Gemfile.lock
|
|
61
|
+
- README.md
|
|
62
|
+
- Rakefile
|
|
63
|
+
- bin/console
|
|
64
|
+
- bin/setup
|
|
65
|
+
- fibered_mysql2.gemspec
|
|
66
|
+
- gemfiles/rails_4.gemfile
|
|
67
|
+
- gemfiles/rails_5.gemfile
|
|
68
|
+
- gemfiles/rails_6.gemfile
|
|
69
|
+
- lib/fibered_mysql2.rb
|
|
70
|
+
- lib/fibered_mysql2/fibered_mysql2_adapter.rb
|
|
71
|
+
- lib/fibered_mysql2/version.rb
|
|
72
|
+
homepage: https://github.com/Invoca/fibered_mysql2
|
|
73
|
+
licenses: []
|
|
74
|
+
metadata:
|
|
75
|
+
allowed_push_host: https://rubygems.org
|
|
76
|
+
homepage_uri: https://github.com/Invoca/fibered_mysql2
|
|
77
|
+
post_install_message:
|
|
78
|
+
rdoc_options: []
|
|
79
|
+
require_paths:
|
|
80
|
+
- lib
|
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">"
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: 1.3.1
|
|
91
|
+
requirements: []
|
|
92
|
+
rubygems_version: 3.0.1
|
|
93
|
+
signing_key:
|
|
94
|
+
specification_version: 4
|
|
95
|
+
summary: An adapter for fibered mysql2
|
|
96
|
+
test_files: []
|