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: 686e66ecfa5fe2b18eb2810446429d5f0a0106b3593f8282794fe0badd8c8d76
4
- data.tar.gz: faa4c1216495dcdff5dd9735f6a8a300442ddbe2dce31812458ba38a093dcc26
3
+ metadata.gz: 14341c3b793112061aa9934a52cebb26ce5f109873ad66d6c73956377392df75
4
+ data.tar.gz: 1b571b948cc5823906ca438a4cb43edc0c2a3a606441160a5263ac0aa10f3b22
5
5
  SHA512:
6
- metadata.gz: 4b776c4c4f891df6b1a2ccf0088ec20f96dfd08b331e2df19f28daa55858bcb7bdf8b8c081891c39f133ba1afcb087736f50a7f21491fb7fbbafc14a44f6cd9b
7
- data.tar.gz: 1fb5be2c7c30c165b46a9c89b953eef359ac475c559b1661e7ddd176abfbde2d269d970fb3767d441762190a14f96a867dde5fa038766bb9670a3dd0bf4cea92
6
+ metadata.gz: 074ee670599ad1e31ede07877e3b2956e6e99d332c19bea36d3f32b257523c8d99b7c23ce5ede83ec45085ecb3162960f170c3c0e27796905203c63c32dabd7d
7
+ data.tar.gz: 3a26877200c88facb93a1dabd2bb069af8d2c8bcffa0299258c6503259dc47fb4e2503b0194f1946d6cf160c7699be10cbbb4874f681514ab221fb45320d2c15
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fibered_mysql2 (0.3.2.pre.tstarck.5)
4
+ fibered_mysql2 (0.3.2.pre.tstarck.7)
5
5
  em-synchrony (~> 1.0)
6
6
  rails (>= 7.0, < 7.2)
7
7
 
@@ -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 FiberedMysql2Adapter_5_2
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
- include FiberedMysql2Adapter_5_2
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
- include Adapter_7_0 if ActiveRecord.gem_version < "7.1"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiberedMysql2
4
- VERSION = "0.3.2.pre.tstarck.5"
4
+ VERSION = "0.3.2.pre.tstarck.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fibered_mysql2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2.pre.tstarck.5
4
+ version: 0.3.2.pre.tstarck.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development