fibered_mysql2 0.1.0.pre.4 → 0.1.0.pre.5
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 +4 -4
- data/.rspec +1 -1
- data/CHANGELOG.md +5 -5
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/fibered_mysql2.gemspec +6 -4
- data/lib/fibered_mysql2/fibered_database_connection_pool.rb +34 -32
- data/lib/fibered_mysql2/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dc370ac1991b20233635be62b5987835aaa7f257d1a5205f7b024265a86580d
|
4
|
+
data.tar.gz: ca03aa8ba38ed8b7997967c939fd994bf03c4042ddf3fee99c2b15a0fcdb9250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63e6cabcc9f2e91870802e806017d12140b86d12da87edd4bf4864646207e583aabc76690a4d553ee4b886aae18cc34b5018c1093255ed68d347a9b911b38c96
|
7
|
+
data.tar.gz: 3fe04ea933864b648c50d804f787577c1742aef9dcb0449c4a3510ba51e483186f7715cb0c949ad0aa8ac70afc3f2078ff91476f01b94bf70388f2e0ae21f303
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,9 +6,9 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
6
6
|
|
7
7
|
## [0.1.0] - Unreleased
|
8
8
|
### Added
|
9
|
-
-
|
10
|
-
-
|
11
|
-
- TravisCI unit test pipeline.
|
12
|
-
-
|
9
|
+
- Added an adapter for Rails 4, 5, and 6.
|
10
|
+
- Added appraisals for Rails 4, 5, and 6.
|
11
|
+
- Added TravisCI unit test pipeline.
|
12
|
+
- Added coverage reports via Coveralls.
|
13
13
|
|
14
|
-
[0.1.0]: https://github.com/Invoca/fibered_mysql2/tree/v0.1.0
|
14
|
+
[0.1.0]: https://github.com/Invoca/fibered_mysql2/tree/v0.1.0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,7 +29,7 @@ Behaves the same as `ActiveRecord::ConnectionAdapters::EMMysql2Adapter` but with
|
|
29
29
|
```ruby
|
30
30
|
connection = FiberedMysql2::FiberedMysql2Adapter.new(client, logger, options, config)
|
31
31
|
connection.lease
|
32
|
-
connection.expire
|
32
|
+
connection.expire # Rails 5+ only
|
33
33
|
```
|
34
34
|
|
35
35
|
## Development
|
data/fibered_mysql2.gemspec
CHANGED
@@ -7,16 +7,18 @@ require "fibered_mysql2/version"
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "fibered_mysql2"
|
9
9
|
spec.version = FiberedMysql2::VERSION
|
10
|
-
spec.authors = ["
|
11
|
-
spec.email = ["
|
10
|
+
spec.authors = ["Invoca Development"]
|
11
|
+
spec.email = ["development@invoca.com"]
|
12
12
|
|
13
13
|
spec.summary = "An adapter for fibered mysql2"
|
14
14
|
spec.homepage = "https://github.com/Invoca/fibered_mysql2"
|
15
15
|
|
16
16
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
17
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
-
spec.metadata
|
19
|
-
|
18
|
+
spec.metadata = {
|
19
|
+
"allowed_push_host" => "https://rubygems.org",
|
20
|
+
"homepage_uri" => spec.homepage
|
21
|
+
}
|
20
22
|
|
21
23
|
# Specify which files should be added to the gem when it is released.
|
22
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -124,12 +124,44 @@ module FiberedMysql2
|
|
124
124
|
def cached_connections
|
125
125
|
@reserved_connections
|
126
126
|
end
|
127
|
+
|
128
|
+
def current_connection_id
|
129
|
+
ActiveRecord::Base.connection_id ||= Fiber.current.object_id
|
130
|
+
end
|
131
|
+
|
132
|
+
def checkout
|
133
|
+
begin
|
134
|
+
reap_connections
|
135
|
+
rescue => ex
|
136
|
+
ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex}")
|
137
|
+
end
|
138
|
+
super
|
139
|
+
end
|
127
140
|
end
|
128
141
|
|
129
142
|
module Adapter_5_2
|
130
143
|
def cached_connections
|
131
144
|
@thread_cached_conns
|
132
145
|
end
|
146
|
+
|
147
|
+
def current_connection_id
|
148
|
+
connection_cache_key(current_thread)
|
149
|
+
end
|
150
|
+
|
151
|
+
def checkout(checkout_timeout = @checkout_timeout)
|
152
|
+
begin
|
153
|
+
reap_connections
|
154
|
+
rescue => ex
|
155
|
+
ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex}")
|
156
|
+
end
|
157
|
+
super
|
158
|
+
end
|
159
|
+
|
160
|
+
def release_connection(owner_thread = Fiber.current)
|
161
|
+
if (conn = @thread_cached_conns.delete(connection_cache_key(owner_thread)))
|
162
|
+
checkin(conn)
|
163
|
+
end
|
164
|
+
end
|
133
165
|
end
|
134
166
|
|
135
167
|
case Rails::VERSION::MAJOR
|
@@ -139,10 +171,10 @@ module FiberedMysql2
|
|
139
171
|
include Adapter_5_2
|
140
172
|
end
|
141
173
|
|
142
|
-
def initialize(connection_spec)
|
174
|
+
def initialize(connection_spec, *args, **keyword_args)
|
143
175
|
connection_spec.config[:reaping_frequency] and raise "reaping_frequency is not supported (the ActiveRecord Reaper is thread-based)"
|
144
176
|
|
145
|
-
super(connection_spec)
|
177
|
+
super(connection_spec, *args, **keyword_args)
|
146
178
|
|
147
179
|
@reaper = nil # no need to keep a reference to this since it does nothing in this sub-class
|
148
180
|
|
@@ -165,36 +197,6 @@ module FiberedMysql2
|
|
165
197
|
end
|
166
198
|
end
|
167
199
|
|
168
|
-
if Rails::VERSION::MAJOR > 4
|
169
|
-
def release_connection(owner_thread = Fiber.current)
|
170
|
-
if (conn = @thread_cached_conns.delete(connection_cache_key(owner_thread)))
|
171
|
-
checkin(conn)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def current_connection_id
|
177
|
-
case Rails::VERSION::MAJOR
|
178
|
-
when 4
|
179
|
-
ActiveRecord::Base.connection_id ||= Fiber.current.object_id
|
180
|
-
else
|
181
|
-
connection_cache_key(current_thread)
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
def checkout(checkout_timeout = @checkout_timeout)
|
186
|
-
begin
|
187
|
-
reap_connections
|
188
|
-
rescue => ex
|
189
|
-
ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex}")
|
190
|
-
end
|
191
|
-
if Rails::VERSION::MAJOR > 4
|
192
|
-
super
|
193
|
-
else
|
194
|
-
super()
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
200
|
def reap_connections
|
199
201
|
cached_connections.values.each do |connection|
|
200
202
|
unless connection.owner.alive?
|
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: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Invoca Development
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-synchrony
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '7'
|
47
47
|
description:
|
48
48
|
email:
|
49
|
-
-
|
49
|
+
- development@invoca.com
|
50
50
|
executables: []
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|