fibered_mysql2 0.3.2.pre.tstarck.5 → 0.3.2.pre.tstarck.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14341c3b793112061aa9934a52cebb26ce5f109873ad66d6c73956377392df75
|
4
|
+
data.tar.gz: 1b571b948cc5823906ca438a4cb43edc0c2a3a606441160a5263ac0aa10f3b22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 074ee670599ad1e31ede07877e3b2956e6e99d332c19bea36d3f32b257523c8d99b7c23ce5ede83ec45085ecb3162960f170c3c0e27796905203c63c32dabd7d
|
7
|
+
data.tar.gz: 3a26877200c88facb93a1dabd2bb069af8d2c8bcffa0299258c6503259dc47fb4e2503b0194f1946d6cf160c7699be10cbbb4874f681514ab221fb45320d2c15
|
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ require 'active_record/connection_adapters/mysql2_adapter'
|
|
7
7
|
require 'em-synchrony/mysql2'
|
8
8
|
|
9
9
|
module FiberedMysql2
|
10
|
-
module
|
10
|
+
module FiberedMysql2Adapter_7_0
|
11
11
|
def lease
|
12
12
|
if in_use?
|
13
13
|
msg = "Cannot lease connection, ".dup
|
@@ -62,8 +62,32 @@ module FiberedMysql2
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
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
|
+
|
65
85
|
class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
66
|
-
|
86
|
+
if Rails.gem_version < "7.1"
|
87
|
+
include FiberedMysql2Adapter_7_0
|
88
|
+
else
|
89
|
+
include FiberedMysql2Adapter_7_1
|
90
|
+
end
|
67
91
|
|
68
92
|
class << self
|
69
93
|
# Copied from Mysql2Adapter, except with the EM Mysql2 client
|
@@ -209,7 +209,9 @@ module FiberedMysql2
|
|
209
209
|
Fiber.current
|
210
210
|
end
|
211
211
|
end
|
212
|
-
|
212
|
+
if ActiveRecord.gem_version < "7.1"
|
213
|
+
include Adapter_7_0
|
214
|
+
end
|
213
215
|
|
214
216
|
def initialize(pool_config)
|
215
217
|
if pool_config.db_config.reaping_frequency
|