fibered_mysql2 1.0.0.colin.2 → 1.0.0

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: 4eb4eb8b784857e027f0d40f7f43e96e65b0bf442153831bc07be41030ae646d
4
- data.tar.gz: e1ddc3b9ef66c848cb66b7fd080cd90aef0d6a40fa658ddd6abc1cd39c4ff409
3
+ metadata.gz: 41cb4d0725b7f699c21fd92b704670b2d9d1c6eed7fba14297dd283035fca821
4
+ data.tar.gz: cd196fb2a415466eb1f2ba296e24d0ca1bf0f87d6f8745ea9bf4f14bb4fc0622
5
5
  SHA512:
6
- metadata.gz: f6eb1d2947a2b8c2abcb117f39a888139683206dde1f7d6259fb0aa864b6cfae03939d69b7fb22965d464702fed0efddd8db1c1e8d5141dff79e9feaa4bc05c4
7
- data.tar.gz: ec9ee0570f5e99ddc6add3d86589ce0534ed624cf1ae4daf33f4ae65ba46a251f015c34ff845064fddaf73290ba645cb53e45dce0e53c4fc8a7c029bc2b47262
6
+ metadata.gz: 1e57f523e8651d787ae6e357636d2c2ee77872a02277c85b88147ed1a0e06252d9b9a49f57b5a8caef4177c16d670eca767fcfade00585ceb29d589325339866
7
+ data.tar.gz: f25a91dda4cee006f3891f112bb66c31b67a6ea6fc8ce1fd1bd62c37c4c42faaae029fb9dc56182b10ee27e93d15115b37bdf3f7d4b88da1b5d50e0c2118bf7f
@@ -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/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.0.0] - 2023-05-31
8
+ ### Changed
9
+ - Changed to Ruby 3.2.1 with Async rather than EventMachine+Synchrony. Only support Rails 6.0 as Rails 7
10
+ already has a similar feature: `isolation_level: :fiber`.
11
+
7
12
  ## [0.2.0] - 2023-01-12
8
13
  ### Added
9
14
  - Added support for Rails 6+ by adding knowledge of lazy transactions to the adapter.
@@ -40,11 +45,3 @@ threaded, not fibered.
40
45
  - Added appraisals for Rails 4, 5, and 6.
41
46
  - Added TravisCI unit test pipeline.
42
47
  - Added coverage reports via Coveralls.
43
-
44
- [0.2.0]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.5..v0.2.0
45
- [0.1.5]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.4..v0.1.5
46
- [0.1.4]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.3..v0.1.4
47
- [0.1.3]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.2..v0.1.3
48
- [0.1.2]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.1..v0.1.2
49
- [0.1.1]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.0..v0.1.1
50
- [0.1.0]: https://github.com/Invoca/fibered_mysql2/tree/v0.1.0
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)
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"
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
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
@@ -91,9 +88,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
88
  version: '0'
92
89
  required_rubygems_version: !ruby/object:Gem::Requirement
93
90
  requirements:
94
- - - ">"
91
+ - - ">="
95
92
  - !ruby/object:Gem::Version
96
- version: 1.3.1
93
+ version: '0'
97
94
  requirements: []
98
95
  rubygems_version: 3.4.6
99
96
  signing_key:
@@ -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