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 +4 -4
- data/.github/workflows/build.yml +1 -2
- data/Appraisals +0 -4
- data/CHANGELOG.md +5 -8
- data/Gemfile.lock +2 -2
- data/README.md +5 -4
- data/bin/console +1 -0
- data/fibered_mysql2.gemspec +1 -1
- data/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb +3 -6
- data/lib/fibered_mysql2/fibered_database_connection_pool.rb +1 -5
- data/lib/fibered_mysql2/version.rb +1 -1
- data/lib/fibered_mysql2.rb +4 -9
- metadata +6 -9
- data/gemfiles/rails_5.gemfile +0 -15
- data/lib/fibered_mysql2/async_task.rb +0 -18
- data/lib/fibered_mysql2/fibered_mutex_with_waiter_priority.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41cb4d0725b7f699c21fd92b704670b2d9d1c6eed7fba14297dd283035fca821
|
4
|
+
data.tar.gz: cd196fb2a415466eb1f2ba296e24d0ca1bf0f87d6f8745ea9bf4f14bb4fc0622
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e57f523e8651d787ae6e357636d2c2ee77872a02277c85b88147ed1a0e06252d9b9a49f57b5a8caef4177c16d670eca767fcfade00585ceb29d589325339866
|
7
|
+
data.tar.gz: f25a91dda4cee006f3891f112bb66c31b67a6ea6fc8ce1fd1bd62c37c4c42faaae029fb9dc56182b10ee27e93d15115b37bdf3f7d4b88da1b5d50e0c2118bf7f
|
data/.github/workflows/build.yml
CHANGED
data/Appraisals
CHANGED
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
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
# FiberedMysql2
|
4
4
|
|
5
|
-
FiberedMysql2 adds Fiber support to `ActiveRecord::ConnectionAdapters::
|
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
|
25
|
+
Tested with Rails 6.0, Ruby 3, and Async.
|
25
26
|
|
26
27
|
## Usage
|
27
28
|
|
28
|
-
Behaves the same as `ActiveRecord::ConnectionAdapters::
|
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
|
33
|
+
connection.expire
|
33
34
|
```
|
34
35
|
|
35
36
|
## Development
|
data/bin/console
CHANGED
data/fibered_mysql2.gemspec
CHANGED
@@ -61,12 +61,9 @@ module FiberedMysql2
|
|
61
61
|
end
|
62
62
|
|
63
63
|
class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
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
|
data/lib/fibered_mysql2.rb
CHANGED
@@ -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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
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-
|
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: '
|
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: '
|
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:
|
93
|
+
version: '0'
|
97
94
|
requirements: []
|
98
95
|
rubygems_version: 3.4.6
|
99
96
|
signing_key:
|
data/gemfiles/rails_5.gemfile
DELETED
@@ -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
|