fibered_mysql2 0.1.0.pre.4 → 0.1.0.pre.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52a7c1f9db37bca0d6b9861985ad594863e1cde7847952dc83a2ed94bed72d2e
4
- data.tar.gz: 1ac220f2391d1b7c74df9985ddfaca59855570ee01e36f8351841f8651306a98
3
+ metadata.gz: 4dc370ac1991b20233635be62b5987835aaa7f257d1a5205f7b024265a86580d
4
+ data.tar.gz: ca03aa8ba38ed8b7997967c939fd994bf03c4042ddf3fee99c2b15a0fcdb9250
5
5
  SHA512:
6
- metadata.gz: 4df2ada93ac02bf3b34b6a223c83c26690a620a88eec6c38ffc4f1a1c8a052867fc126b4f745ad3e1aa9278e86a7808c08dc7b493dbd99cb93812895b1901584
7
- data.tar.gz: 78fafb964db2b16da1604032ea1421b2761f81ef60c52851be4df30f96e78a9f688b9a656fec1d4a0ad4b1564aca20f57bb9722a69aba64be4891835d11cfd6e
6
+ metadata.gz: 63e6cabcc9f2e91870802e806017d12140b86d12da87edd4bf4864646207e583aabc76690a4d553ee4b886aae18cc34b5018c1093255ed68d347a9b911b38c96
7
+ data.tar.gz: 3fe04ea933864b648c50d804f787577c1742aef9dcb0449c4a3510ba51e483186f7715cb0c949ad0aa8ac70afc3f2078ff91476f01b94bf70388f2e0ae21f303
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
1
+ --format progress
2
2
  --color
3
3
  --require spec_helper
@@ -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
- - 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.
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fibered_mysql2 (0.1.0.pre.4)
4
+ fibered_mysql2 (0.1.0.pre.5)
5
5
  em-synchrony (~> 1.0)
6
6
  rails (>= 4.2, < 7)
7
7
 
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 // Rails 5+ only
32
+ connection.expire # Rails 5+ only
33
33
  ```
34
34
 
35
35
  ## Development
@@ -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 = ["Octothorp"]
11
- spec.email = ["octothorp@invoca.com"]
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["allowed_push_host"] = "https://rubygems.org"
19
- spec.metadata["homepage_uri"] = spec.homepage
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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiberedMysql2
4
- VERSION = "0.1.0.pre.4"
4
+ VERSION = "0.1.0.pre.5"
5
5
  end
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
4
+ version: 0.1.0.pre.5
5
5
  platform: ruby
6
6
  authors:
7
- - Octothorp
7
+ - Invoca Development
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-13 00:00:00.000000000 Z
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
- - octothorp@invoca.com
49
+ - development@invoca.com
50
50
  executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []