fibered_mysql2 1.0.0.colin.2 → 1.0.0.colin.3
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/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 +4 -7
- 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: 1edbb420eedd78ecab2ae0fef48554d968f01e44c791430262f55b43c280dea0
|
4
|
+
data.tar.gz: 676673438f5078176bfbd836d6e34d79283a1aa8874cbd32563266dbf163a5b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6de1e7d5bd5afe99bb1104d772dcef36bf5414d58e57b069bf2883e506c1a5f78551a429b4ee3098321373bee5ff83ee2a200ba3477ebde9bd15d26cd78fa4f
|
7
|
+
data.tar.gz: e506a05e2ffd01f2c0f7380a9fd644735aceb9843f43f683b1972533f5c37d783ef4aa2b8417aa9e25ef548c03bc837fec7aeb9b16a0e000d6683ab6619d3bf7
|
data/.github/workflows/build.yml
CHANGED
data/Appraisals
CHANGED
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.colin.
|
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-
|
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
|
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
|