fibered_mysql2 1.0.0.colin.2 → 1.0.0.colin.3

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: 4eb4eb8b784857e027f0d40f7f43e96e65b0bf442153831bc07be41030ae646d
4
- data.tar.gz: e1ddc3b9ef66c848cb66b7fd080cd90aef0d6a40fa658ddd6abc1cd39c4ff409
3
+ metadata.gz: 1edbb420eedd78ecab2ae0fef48554d968f01e44c791430262f55b43c280dea0
4
+ data.tar.gz: 676673438f5078176bfbd836d6e34d79283a1aa8874cbd32563266dbf163a5b3
5
5
  SHA512:
6
- metadata.gz: f6eb1d2947a2b8c2abcb117f39a888139683206dde1f7d6259fb0aa864b6cfae03939d69b7fb22965d464702fed0efddd8db1c1e8d5141dff79e9feaa4bc05c4
7
- data.tar.gz: ec9ee0570f5e99ddc6add3d86589ce0534ed624cf1ae4daf33f4ae65ba46a251f015c34ff845064fddaf73290ba645cb53e45dce0e53c4fc8a7c029bc2b47262
6
+ metadata.gz: a6de1e7d5bd5afe99bb1104d772dcef36bf5414d58e57b069bf2883e506c1a5f78551a429b4ee3098321373bee5ff83ee2a200ba3477ebde9bd15d26cd78fa4f
7
+ data.tar.gz: e506a05e2ffd01f2c0f7380a9fd644735aceb9843f43f683b1972533f5c37d783ef4aa2b8417aa9e25ef548c03bc837fec7aeb9b16a0e000d6683ab6619d3bf7
@@ -8,10 +8,9 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [2.5, 2.6, 2.7, '3.0', 3.1]
11
+ ruby: [3.1, 3.2]
12
12
  gemfile:
13
13
  - Gemfile
14
- - gemfiles/rails_5.gemfile
15
14
  - gemfiles/rails_6.gemfile
16
15
  env:
17
16
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
data/Appraisals CHANGED
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'rails-5' do
4
- gem 'rails', '~> 5.2'
5
- end
6
-
7
3
  appraise 'rails-6' do
8
4
  gem 'rails', '~> 6.0.0'
9
5
  end
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fibered_mysql2 (1.0.0.colin.2)
4
+ fibered_mysql2 (1.0.0.colin.3)
5
5
  async
6
- rails (>= 5.2, < 7)
6
+ rails (>= 6, < 7)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  # FiberedMysql2
4
4
 
5
- FiberedMysql2 adds Fiber support to `ActiveRecord::ConnectionAdapters::EMMysql2Adapter`
5
+ FiberedMysql2 adds Fiber support to `ActiveRecord::ConnectionAdapters::Mysql2Adapter` for Rails 6.
6
+ This is a stop-gap until Rails 7, which adds `isolation_level: :fiber` to `ActiveRecord`.
6
7
 
7
8
  ## Installation
8
9
 
@@ -21,15 +22,15 @@ Or install it yourself as:
21
22
  $ gem install fibered_mysql2
22
23
 
23
24
  ## Support
24
- Tested with Rails versions 5.2 and 6.0.
25
+ Tested with Rails 6.0, Ruby 3, and Async.
25
26
 
26
27
  ## Usage
27
28
 
28
- Behaves the same as `ActiveRecord::ConnectionAdapters::EMMysql2Adapter` but with added Fiber safety while leasing/expiring connections.
29
+ Behaves the same as `ActiveRecord::ConnectionAdapters::Mysql2Adapter` but with using Fibers rather than Threads for tracking ownership when leasing/expiring connections.
29
30
  ```ruby
30
31
  connection = FiberedMysql2::FiberedMysql2Adapter.new(client, logger, options, config)
31
32
  connection.lease
32
- connection.expire # Rails 5+ only
33
+ connection.expire
33
34
  ```
34
35
 
35
36
  ## Development
data/bin/console CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
+ require "active_record"
4
5
  require "fibered_mysql2"
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_dependency 'async'
33
- spec.add_dependency 'rails', '>= 5.2', '< 7'
33
+ spec.add_dependency 'rails', '>= 6', '< 7'
34
34
  end
@@ -61,12 +61,9 @@ module FiberedMysql2
61
61
  end
62
62
 
63
63
  class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
64
- case ::Rails::VERSION::MAJOR
65
- when 6
66
- include FiberedMysql2Adapter_6
67
- else
68
- raise ArgumentError, "unexpected Rails version #{Rails::VERSION::MAJOR}"
69
- end
64
+ ActiveRecord::VERSION::MAJOR == 6 or raise ArgumentError, "unexpected Rails version #{ActiveRecord::VERSION::MAJOR}"
65
+
66
+ include FiberedMysql2Adapter_6
70
67
 
71
68
  def initialize(*args)
72
69
  super
@@ -4,11 +4,7 @@
4
4
 
5
5
  module FiberedMysql2
6
6
  module FiberedDatabaseConnectionPool
7
- case ::Rails::VERSION::MAJOR
8
- when 6
9
- else
10
- raise ArgumentError, "unexpected Rails version #{Rails::VERSION::MAJOR}"
11
- end
7
+ ActiveRecord::VERSION::MAJOR == 6 or raise ArgumentError, "unexpected Rails version #{ActiveRecord::VERSION::MAJOR}"
12
8
 
13
9
  def cached_connections
14
10
  @thread_cached_conns
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiberedMysql2
4
- VERSION = "1.0.0.colin.2"
4
+ VERSION = "1.0.0.colin.3"
5
5
  end
@@ -1,13 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'async'
4
- require 'fibered_mysql2/version'
5
- require_relative '../lib/active_record/connection_adapters/fibered_mysql2_adapter'
6
- require 'fibered_mysql2/fibered_database_connection_pool'
7
- require 'fibered_mysql2/fibered_mutex_with_waiter_priority'
8
- require 'fibered_mysql2/fibered_mysql2_connection_factory'
9
4
 
10
- module FiberedMysql2
11
- class Error < StandardError; end
12
- # Your code goes here...
13
- end
5
+ require_relative 'active_record/connection_adapters/fibered_mysql2_adapter'
6
+ require_relative 'fibered_mysql2/fibered_database_connection_pool'
7
+ require_relative 'fibered_mysql2/fibered_mysql2_connection_factory'
8
+ require_relative 'fibered_mysql2/version'
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: 1.0.0.colin.2
4
+ version: 1.0.0.colin.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-30 00:00:00.000000000 Z
11
+ date: 2023-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.2'
33
+ version: '6'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '7'
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '5.2'
43
+ version: '6'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '7'
@@ -66,13 +66,10 @@ files:
66
66
  - bin/console
67
67
  - bin/setup
68
68
  - fibered_mysql2.gemspec
69
- - gemfiles/rails_5.gemfile
70
69
  - gemfiles/rails_6.gemfile
71
70
  - lib/active_record/connection_adapters/fibered_mysql2_adapter.rb
72
71
  - lib/fibered_mysql2.rb
73
- - lib/fibered_mysql2/async_task.rb
74
72
  - lib/fibered_mysql2/fibered_database_connection_pool.rb
75
- - lib/fibered_mysql2/fibered_mutex_with_waiter_priority.rb
76
73
  - lib/fibered_mysql2/fibered_mysql2_connection_factory.rb
77
74
  - lib/fibered_mysql2/version.rb
78
75
  homepage: https://github.com/Invoca/fibered_mysql2
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "coveralls", require: false
7
- gem "mysql2", "~> 0.5"
8
- gem "nokogiri", "< 1.13"
9
- gem "pry", "~> 0.13"
10
- gem "pry-byebug", "~> 3.9"
11
- gem "rails", "~> 5.2"
12
- gem "rake", "~> 13.0"
13
- gem "rspec", "~> 3.0"
14
-
15
- gemspec path: "../"
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FiberedMysql2
4
- module AsyncTask
5
- class NoTaskPlaceholder
6
- class << self
7
- def alive? = true
8
- end
9
- end
10
-
11
- class << self
12
- # Adapted from https://github.com/socketry/async/blob/main/lib/async/task.rb#L236-L238
13
- def current_or_none
14
- Thread.current[:async_task] || NoTaskPlaceholder
15
- end
16
- end
17
- end
18
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FiberedMysql2
4
- module FiberedMutexWithWaiterPriority
5
- # Note: @waiters is a bit confusing because the first waiter is actually the current fiber that has it locked;
6
- # the _rest_ of @waiters are the actual waiters
7
- def sleep(timeout = nil)
8
- unlock
9
- beg = Time.now
10
- current = Fiber.current
11
- @slept[current] = true
12
- if timeout
13
- timer = EM.add_timer(timeout) do
14
- _wakeup(current)
15
- end
16
- Fiber.yield
17
- EM.cancel_timer(timer) # if we resumed not via timer
18
- else
19
- Fiber.yield
20
- end
21
- @slept.delete(current)
22
- yield if block_given?
23
-
24
- # Invoca patch: inline lock that puts us at the front of the mutex @waiters queue instead of the back
25
- # ==========================
26
- @waiters.unshift(current)
27
- Fiber.yield if @waiters.size > 1
28
- # ==========================
29
-
30
- Time.now - beg
31
- end
32
- end
33
- end