rails_failover 2.1.1 → 2.3.0
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 +4 -4
- data/.github/workflows/ci.yml +8 -6
- data/.gitignore +1 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -0
- data/README.md +21 -1
- data/lib/rails_failover/redis/{connector.rb → compat_4x/connector.rb} +5 -5
- data/lib/rails_failover/redis/compat_4x/handler.rb +26 -0
- data/lib/{redis → rails_failover/redis/compat_4x}/patches/client.rb +3 -0
- data/lib/rails_failover/redis/compat_5x/client.rb +21 -0
- data/lib/rails_failover/redis/compat_5x/config.rb +59 -0
- data/lib/rails_failover/redis/compat_5x/handler.rb +22 -0
- data/lib/rails_failover/redis/compat_5x/patches/client.rb +27 -0
- data/lib/rails_failover/redis/{handler.rb → handler_base.rb} +31 -41
- data/lib/rails_failover/redis.rb +8 -2
- data/lib/rails_failover/version.rb +1 -1
- data/rails_failover.gemspec +3 -3
- metadata +23 -17
- data/Gemfile.lock +0 -205
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a29875bc4c61fb00a94064e967da8785baeb2f78951b340b42ceeeb9e20a37d4
|
4
|
+
data.tar.gz: 1ea2a3785aaa878bd60900afabcfc1549e0411c25d21ec87ef9f6bff72ba4c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03a99ae6d38c4aec59dc924ca4fe2f9eda771ba013412e652a83f666e6d97b98c7fa6cadaa4a977dd28ff58e7188216fe81b2ea54faba472f2f9b22b0181e0da
|
7
|
+
data.tar.gz: 97f2d01b2f4fd314befa54726f3067be2c4a1b7d659bd0fb254166c8c1d6fc329c74dd80a7acb3f0124f80188e36cb3e742d569830c8740bd2c67ffd271a0d48
|
data/.github/workflows/ci.yml
CHANGED
@@ -29,13 +29,14 @@ jobs:
|
|
29
29
|
bundle exec stree check Gemfile rails_failover.gemspec $(git ls-files '*.rb')
|
30
30
|
|
31
31
|
redis:
|
32
|
-
name: "Redis (Ruby ${{ matrix.ruby }})"
|
32
|
+
name: "Redis (Redis gem ~> ${{ matrix.redis_gem }}, Ruby ${{ matrix.ruby }})"
|
33
33
|
runs-on: ubuntu-latest
|
34
34
|
|
35
35
|
strategy:
|
36
36
|
fail-fast: false
|
37
37
|
matrix:
|
38
38
|
ruby: ["3.4", "3.3", "3.2", "3.1"]
|
39
|
+
redis_gem: ["4.8", "5.3"]
|
39
40
|
|
40
41
|
steps:
|
41
42
|
- uses: actions/checkout@v3
|
@@ -46,12 +47,16 @@ jobs:
|
|
46
47
|
ruby-version: ${{ matrix.ruby }}
|
47
48
|
|
48
49
|
- name: Setup gems
|
50
|
+
env:
|
51
|
+
REDIS_GEM_VERSION: ${{ matrix.redis_gem }}
|
49
52
|
run: bundle install
|
50
53
|
|
51
54
|
- name: Setup redis
|
52
55
|
run: sudo apt-get install redis-server
|
53
56
|
|
54
57
|
- name: Redis specs
|
58
|
+
env:
|
59
|
+
REDIS_GEM_VERSION: ${{ matrix.redis_gem }}
|
55
60
|
run: bin/rspec redis
|
56
61
|
|
57
62
|
active_record:
|
@@ -61,11 +66,8 @@ jobs:
|
|
61
66
|
strategy:
|
62
67
|
fail-fast: false
|
63
68
|
matrix:
|
64
|
-
ruby: ["3.4", "3.3", "3.2"
|
65
|
-
rails: ["
|
66
|
-
include:
|
67
|
-
- ruby: "3.2"
|
68
|
-
rails: "6.1.0"
|
69
|
+
ruby: ["3.4", "3.3", "3.2"]
|
70
|
+
rails: ["8.0.0", "7.2.0", "7.1.0"]
|
69
71
|
exclude:
|
70
72
|
- ruby: "3.4"
|
71
73
|
rails: "7.0.0"
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [2.3.0] - 2025-06-17
|
9
|
+
|
10
|
+
- DEV: Add compatibility with Rails 8.0+
|
11
|
+
|
12
|
+
## [2.2.0] - 2025-01-29
|
13
|
+
|
14
|
+
- DEV: Add compatibility with the Redis gem version 5.x
|
15
|
+
|
8
16
|
## [2.1.1] - 2024-07-02
|
9
17
|
|
10
18
|
- FIX: Falling back to primary PG server not reliable on Rails 7.1
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -79,7 +79,25 @@ connects_to database: { writing: :primary, second_database_writing: :second_data
|
|
79
79
|
Add `require 'rails_failover/redis'` before creating a `Redis` instance.
|
80
80
|
|
81
81
|
```ruby
|
82
|
-
Redis
|
82
|
+
# Redis/RedisClient 4.x
|
83
|
+
Redis.new(
|
84
|
+
host: "127.0.0.1",
|
85
|
+
port: 6379,
|
86
|
+
replica_host: "127.0.0.1",
|
87
|
+
replica_port: 6380,
|
88
|
+
connector: RailsFailover::Redis::Connector,
|
89
|
+
)
|
90
|
+
|
91
|
+
# Redis/RedisClient 5.x
|
92
|
+
Redis.new(
|
93
|
+
host: "127.0.0.1",
|
94
|
+
port: 6379,
|
95
|
+
client_implementation: RailsFailover::Redis::Client,
|
96
|
+
custom: {
|
97
|
+
replica_host: "127.0.0.1",
|
98
|
+
replica_port: 6380,
|
99
|
+
}
|
100
|
+
)
|
83
101
|
```
|
84
102
|
|
85
103
|
Callbacks can be registered when the primary connection is down and when it is up.
|
@@ -94,6 +112,8 @@ RailsFailover::Redis.on_fallback_callback do
|
|
94
112
|
end
|
95
113
|
```
|
96
114
|
|
115
|
+
> ⚠️ If you’re using Sidekiq, don’t provide it with the replica configuration as it won’t work. RailsFailover works with a replica in read-only mode, meaning Sidekiq wouldn’t work properly anyway as it needs to write to Redis.
|
116
|
+
|
97
117
|
## Development
|
98
118
|
|
99
119
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -9,6 +9,7 @@ module RailsFailover
|
|
9
9
|
original_driver = options[:driver]
|
10
10
|
options[:primary_host] = options[:host]
|
11
11
|
options[:primary_port] = options[:port]
|
12
|
+
options[:id] ||= "#{options[:host]}:#{options[:port]}"
|
12
13
|
|
13
14
|
options[:driver] = Class.new(options[:driver]) do
|
14
15
|
def self.connect(options)
|
@@ -40,25 +41,24 @@ module RailsFailover
|
|
40
41
|
|
41
42
|
options[:original_driver] = original_driver
|
42
43
|
options.delete(:connector)
|
43
|
-
options[:id] ||= "#{options[:host]}:#{options[:port]}"
|
44
44
|
@replica_options = replica_options(options)
|
45
45
|
@options = options.dup
|
46
46
|
end
|
47
47
|
|
48
48
|
def resolve
|
49
|
-
Handler.instance.primary_down?(@options) ? @replica_options : @options
|
49
|
+
Handler.instance.primary_down?(@options[:id]) ? @replica_options : @options
|
50
50
|
end
|
51
51
|
|
52
52
|
def check(client)
|
53
|
-
Handler.instance.register_client(client)
|
54
|
-
expected_role = Handler.instance.primary_down?(@options) ? REPLICA : PRIMARY
|
53
|
+
Handler.instance.register_client(client, client.options[:id])
|
54
|
+
expected_role = Handler.instance.primary_down?(@options[:id]) ? REPLICA : PRIMARY
|
55
55
|
if client.connection.rails_failover_role != expected_role
|
56
56
|
raise ::Redis::CannotConnectError, "Opened with unexpected failover role"
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
def on_disconnect(client)
|
61
|
-
Handler.instance.deregister_client(client)
|
61
|
+
Handler.instance.deregister_client(client, client.options[:id])
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../handler_base"
|
4
|
+
|
5
|
+
module RailsFailover
|
6
|
+
class Redis
|
7
|
+
class Handler < HandlerBase
|
8
|
+
def new_primary_client(options)
|
9
|
+
options[:driver] = options[:original_driver]
|
10
|
+
::Redis::Client.new(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def primary_client_info(client)
|
14
|
+
client.call([:info])
|
15
|
+
end
|
16
|
+
|
17
|
+
def soft_disconnect_original_client(matched_clients, redis, role)
|
18
|
+
# When subscribed, Redis#_client is not a Redis::Client
|
19
|
+
# Instance variable is the only reliable way
|
20
|
+
client = redis.instance_variable_get(:@original_client)
|
21
|
+
return if !matched_clients.include?(client)
|
22
|
+
soft_disconnect(redis, client, role)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "redis"
|
4
|
+
require "active_support/core_ext/module/delegation"
|
4
5
|
|
5
6
|
# See https://github.com/redis/redis-rb/pull/908
|
6
7
|
class Redis::Client
|
8
|
+
delegate :rails_failover_role, :shutdown_socket, to: :connection, allow_nil: true
|
9
|
+
|
7
10
|
def disconnect
|
8
11
|
if connected?
|
9
12
|
result = connection.disconnect
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsFailover
|
4
|
+
class Redis
|
5
|
+
class Client < ::Redis::Client
|
6
|
+
def initialize(config, **kwargs)
|
7
|
+
super
|
8
|
+
@config = RailsFailover::Redis::Config.new(config)
|
9
|
+
end
|
10
|
+
|
11
|
+
def connect
|
12
|
+
Handler.instance.register_client(self, id)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_disconnect
|
17
|
+
Handler.instance.deregister_client(self, id)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "delegate"
|
4
|
+
require_relative "handler"
|
5
|
+
|
6
|
+
module RailsFailover
|
7
|
+
class Redis
|
8
|
+
class Config < SimpleDelegator
|
9
|
+
attr_reader :driver, :primary_host, :primary_port, :id
|
10
|
+
attr_accessor :rails_failover_role
|
11
|
+
|
12
|
+
def initialize(object)
|
13
|
+
super
|
14
|
+
@primary_host = object.host
|
15
|
+
@primary_port = object.port
|
16
|
+
@id ||= "#{object.host}:#{object.port}"
|
17
|
+
@driver =
|
18
|
+
Class.new(object.driver) do
|
19
|
+
def connect
|
20
|
+
is_primary =
|
21
|
+
(config.host == config.primary_host) && (config.port == config.primary_port)
|
22
|
+
super.tap { config.rails_failover_role = is_primary ? PRIMARY : REPLICA }
|
23
|
+
rescue ::Redis::TimeoutError,
|
24
|
+
RedisClient::CannotConnectError,
|
25
|
+
SocketError,
|
26
|
+
Errno::EADDRNOTAVAIL,
|
27
|
+
Errno::ECONNREFUSED,
|
28
|
+
Errno::EHOSTDOWN,
|
29
|
+
Errno::EHOSTUNREACH,
|
30
|
+
Errno::ENETUNREACH,
|
31
|
+
Errno::ENOENT,
|
32
|
+
Errno::ETIMEDOUT,
|
33
|
+
Errno::EINVAL => e
|
34
|
+
Handler.instance.verify_primary(config) if is_primary
|
35
|
+
raise e
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def host
|
41
|
+
return super unless Handler.instance.primary_down?(id)
|
42
|
+
custom[:replica_host]
|
43
|
+
end
|
44
|
+
|
45
|
+
def port
|
46
|
+
return super unless Handler.instance.primary_down?(id)
|
47
|
+
custom[:replica_port]
|
48
|
+
end
|
49
|
+
|
50
|
+
def new_primary_client
|
51
|
+
::Redis::Client.new(__getobj__)
|
52
|
+
end
|
53
|
+
|
54
|
+
def [](key)
|
55
|
+
instance_variable_get("@#{key}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../handler_base"
|
4
|
+
|
5
|
+
module RailsFailover
|
6
|
+
class Redis
|
7
|
+
class Handler < HandlerBase
|
8
|
+
def new_primary_client(config)
|
9
|
+
config.new_primary_client
|
10
|
+
end
|
11
|
+
|
12
|
+
def primary_client_info(client)
|
13
|
+
client.call_v([:info])
|
14
|
+
end
|
15
|
+
|
16
|
+
def soft_disconnect_original_client(matched_clients, redis, role)
|
17
|
+
return if !matched_clients.include?(redis._client)
|
18
|
+
soft_disconnect(redis, redis._client, role)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "redis"
|
4
|
+
require "active_support/core_ext/module/delegation"
|
5
|
+
|
6
|
+
class Redis::Client
|
7
|
+
delegate :rails_failover_role, to: :config, allow_nil: true
|
8
|
+
|
9
|
+
alias shutdown_socket close
|
10
|
+
|
11
|
+
def disconnect
|
12
|
+
close
|
13
|
+
on_disconnect
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_disconnect
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Redis::SubscribedClient
|
22
|
+
delegate :connected?, to: :@client
|
23
|
+
end
|
24
|
+
|
25
|
+
class RedisClient::PubSub
|
26
|
+
delegate :connected?, to: :@raw_connection, allow_nil: true
|
27
|
+
end
|
@@ -6,7 +6,7 @@ require "concurrent"
|
|
6
6
|
|
7
7
|
module RailsFailover
|
8
8
|
class Redis
|
9
|
-
class
|
9
|
+
class HandlerBase
|
10
10
|
include Singleton
|
11
11
|
include MonitorMixin
|
12
12
|
|
@@ -23,8 +23,8 @@ module RailsFailover
|
|
23
23
|
super() # Monitor#initialize
|
24
24
|
end
|
25
25
|
|
26
|
-
def verify_primary(
|
27
|
-
primary_down(
|
26
|
+
def verify_primary(config)
|
27
|
+
primary_down(config)
|
28
28
|
|
29
29
|
mon_synchronize do
|
30
30
|
return if @thread&.alive?
|
@@ -33,18 +33,16 @@ module RailsFailover
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def register_client(client)
|
37
|
-
id = client.options[:id]
|
36
|
+
def register_client(client, id)
|
38
37
|
clients_for_id(id).put_if_absent(client, true)
|
39
38
|
end
|
40
39
|
|
41
|
-
def deregister_client(client)
|
42
|
-
id = client.options[:id]
|
40
|
+
def deregister_client(client, id)
|
43
41
|
clients_for_id(id).delete(client)
|
44
42
|
end
|
45
43
|
|
46
|
-
def primary_down?(
|
47
|
-
primaries_down[
|
44
|
+
def primary_down?(id)
|
45
|
+
primaries_down[id]
|
48
46
|
end
|
49
47
|
|
50
48
|
def primaries_down_count
|
@@ -71,15 +69,14 @@ module RailsFailover
|
|
71
69
|
|
72
70
|
active_primaries_keys = {}
|
73
71
|
|
74
|
-
primaries_down.each do |key,
|
72
|
+
primaries_down.each do |key, config|
|
75
73
|
info = nil
|
76
|
-
|
74
|
+
config = config.dup
|
77
75
|
|
78
76
|
begin
|
79
|
-
|
80
|
-
primary_client = ::Redis::Client.new(options)
|
77
|
+
primary_client = new_primary_client(config)
|
81
78
|
logger&.debug "Checking connection to primary server (#{key})"
|
82
|
-
info = primary_client
|
79
|
+
info = primary_client_info(primary_client)
|
83
80
|
rescue => e
|
84
81
|
logger&.debug "Connection to primary server (#{key}) failed with '#{e.message}'"
|
85
82
|
ensure
|
@@ -87,14 +84,14 @@ module RailsFailover
|
|
87
84
|
end
|
88
85
|
|
89
86
|
if info && info.include?(PRIMARY_LOADED_STATUS) && info.include?(PRIMARY_ROLE_STATUS)
|
90
|
-
active_primaries_keys[key] =
|
87
|
+
active_primaries_keys[key] = config
|
91
88
|
logger&.debug "Primary server (#{key}) is active, disconnecting clients from replica"
|
92
89
|
end
|
93
90
|
end
|
94
91
|
|
95
|
-
active_primaries_keys.each do |key,
|
96
|
-
primary_up(
|
97
|
-
disconnect_clients(
|
92
|
+
active_primaries_keys.each do |key, config|
|
93
|
+
primary_up(config)
|
94
|
+
disconnect_clients(config[:id], RailsFailover::Redis::REPLICA)
|
98
95
|
end
|
99
96
|
end
|
100
97
|
|
@@ -102,14 +99,14 @@ module RailsFailover
|
|
102
99
|
primaries_down.empty?
|
103
100
|
end
|
104
101
|
|
105
|
-
def primary_up(
|
106
|
-
already_up = !primaries_down.delete(
|
107
|
-
RailsFailover::Redis.on_fallback_callback!(
|
102
|
+
def primary_up(config)
|
103
|
+
already_up = !primaries_down.delete(config[:id])
|
104
|
+
RailsFailover::Redis.on_fallback_callback!(config[:id]) if !already_up
|
108
105
|
end
|
109
106
|
|
110
|
-
def primary_down(
|
111
|
-
already_down = primaries_down.put_if_absent(
|
112
|
-
RailsFailover::Redis.on_failover_callback!(
|
107
|
+
def primary_down(config)
|
108
|
+
already_down = primaries_down.put_if_absent(config[:id], config.dup)
|
109
|
+
RailsFailover::Redis.on_failover_callback!(config[:id]) if !already_down
|
113
110
|
end
|
114
111
|
|
115
112
|
def primaries_down
|
@@ -121,7 +118,7 @@ module RailsFailover
|
|
121
118
|
end
|
122
119
|
|
123
120
|
ancestor_pids&.each do |pid|
|
124
|
-
@primaries_down.delete(pid)&.each { |id,
|
121
|
+
@primaries_down.delete(pid)&.each { |id, config| verify_primary(config) }
|
125
122
|
end
|
126
123
|
|
127
124
|
value
|
@@ -143,27 +140,21 @@ module RailsFailover
|
|
143
140
|
end
|
144
141
|
|
145
142
|
def ensure_primary_clients_disconnected
|
146
|
-
primaries_down.each do |key,
|
147
|
-
disconnect_clients(
|
143
|
+
primaries_down.each do |key, config|
|
144
|
+
disconnect_clients(config[:id], RailsFailover::Redis::PRIMARY)
|
148
145
|
end
|
149
146
|
end
|
150
147
|
|
151
|
-
def disconnect_clients(
|
152
|
-
id = options[:id]
|
153
|
-
|
148
|
+
def disconnect_clients(id, role)
|
154
149
|
matched_clients =
|
155
|
-
clients_for_id(id)&.keys&.
|
150
|
+
clients_for_id(id)&.keys&.select { _1.rails_failover_role == role }&.to_set
|
156
151
|
|
157
152
|
return if matched_clients.nil? || matched_clients.empty?
|
158
153
|
|
159
154
|
# This is not ideal, but the mutex we need is contained
|
160
155
|
# in the ::Redis instance, not the Redis::Client
|
161
156
|
ObjectSpace.each_object(::Redis) do |redis|
|
162
|
-
|
163
|
-
# Instance variable is the only reliable way
|
164
|
-
client = redis.instance_variable_get(:@original_client)
|
165
|
-
next if !matched_clients.include?(client)
|
166
|
-
soft_disconnect(redis, client, role)
|
157
|
+
soft_disconnect_original_client(matched_clients, redis, role)
|
167
158
|
end
|
168
159
|
end
|
169
160
|
|
@@ -174,7 +165,7 @@ module RailsFailover
|
|
174
165
|
|
175
166
|
if !has_lock
|
176
167
|
begin
|
177
|
-
client.
|
168
|
+
client.shutdown_socket
|
178
169
|
rescue => e
|
179
170
|
logger&.warn "Redis shutdown_socket for (#{role}) failed with #{e.class} '#{e.message}'"
|
180
171
|
end
|
@@ -182,15 +173,14 @@ module RailsFailover
|
|
182
173
|
waiting_since = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
183
174
|
loop do # Keep trying
|
184
175
|
break if has_lock = redis_mon_try_enter(redis)
|
185
|
-
break if !client.
|
186
|
-
break if client.
|
176
|
+
break if !client.connected? # Disconnected by other thread
|
177
|
+
break if client.rails_failover_role != role # Reconnected by other thread
|
187
178
|
time_now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
188
179
|
break if time_now > waiting_since + SOFT_DISCONNECT_TIMEOUT_SECONDS
|
189
180
|
sleep SOFT_DISCONNECT_POLL_SECONDS
|
190
181
|
end
|
191
182
|
end
|
192
|
-
|
193
|
-
client.disconnect if client.connection&.rails_failover_role == role
|
183
|
+
client.disconnect if client.rails_failover_role == role
|
194
184
|
ensure
|
195
185
|
redis_mon_exit(redis) if has_lock
|
196
186
|
end
|
data/lib/rails_failover/redis.rb
CHANGED
@@ -8,8 +8,14 @@ if Gem::Version.new(Redis::VERSION) < Gem::Version.new(supported_version)
|
|
8
8
|
raise "redis #{Redis::VERSION} is not supported. Please upgrade to Redis #{supported_version}."
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
require_relative "redis/
|
11
|
+
if Redis::VERSION >= "5"
|
12
|
+
require_relative "redis/compat_5x/patches/client"
|
13
|
+
require_relative "redis/compat_5x/config"
|
14
|
+
require_relative "redis/compat_5x/client"
|
15
|
+
else
|
16
|
+
require_relative "redis/compat_4x/patches/client"
|
17
|
+
require_relative "redis/compat_4x/connector"
|
18
|
+
end
|
13
19
|
|
14
20
|
module RailsFailover
|
15
21
|
class Redis
|
data/rails_failover.gemspec
CHANGED
@@ -23,12 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_dependency "activerecord", ">= 6.1", "<
|
27
|
-
spec.add_dependency "railties", ">= 6.1", "<
|
26
|
+
spec.add_dependency "activerecord", ">= 6.1", "< 9.0"
|
27
|
+
spec.add_dependency "railties", ">= 6.1", "< 9.0"
|
28
28
|
spec.add_dependency "concurrent-ruby"
|
29
29
|
|
30
30
|
spec.add_development_dependency "rake"
|
31
|
-
spec.add_development_dependency "redis", "
|
31
|
+
spec.add_development_dependency "redis", ">= 4.1", "< 6.0"
|
32
32
|
spec.add_development_dependency "pg"
|
33
33
|
spec.add_development_dependency "rack"
|
34
34
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_failover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Tan
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activerecord
|
@@ -19,7 +18,7 @@ dependencies:
|
|
19
18
|
version: '6.1'
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
21
|
+
version: '9.0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +28,7 @@ dependencies:
|
|
29
28
|
version: '6.1'
|
30
29
|
- - "<"
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
31
|
+
version: '9.0'
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: railties
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +38,7 @@ dependencies:
|
|
39
38
|
version: '6.1'
|
40
39
|
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
41
|
+
version: '9.0'
|
43
42
|
type: :runtime
|
44
43
|
prerelease: false
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +48,7 @@ dependencies:
|
|
49
48
|
version: '6.1'
|
50
49
|
- - "<"
|
51
50
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
51
|
+
version: '9.0'
|
53
52
|
- !ruby/object:Gem::Dependency
|
54
53
|
name: concurrent-ruby
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,16 +81,22 @@ dependencies:
|
|
82
81
|
name: redis
|
83
82
|
requirement: !ruby/object:Gem::Requirement
|
84
83
|
requirements:
|
85
|
-
- - "
|
84
|
+
- - ">="
|
86
85
|
- !ruby/object:Gem::Version
|
87
86
|
version: '4.1'
|
87
|
+
- - "<"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '6.0'
|
88
90
|
type: :development
|
89
91
|
prerelease: false
|
90
92
|
version_requirements: !ruby/object:Gem::Requirement
|
91
93
|
requirements:
|
92
|
-
- - "
|
94
|
+
- - ">="
|
93
95
|
- !ruby/object:Gem::Version
|
94
96
|
version: '4.1'
|
97
|
+
- - "<"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '6.0'
|
95
100
|
- !ruby/object:Gem::Dependency
|
96
101
|
name: pg
|
97
102
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,7 +195,6 @@ dependencies:
|
|
190
195
|
- - ">="
|
191
196
|
- !ruby/object:Gem::Version
|
192
197
|
version: '0'
|
193
|
-
description:
|
194
198
|
email:
|
195
199
|
- tgx@discourse.org
|
196
200
|
executables: []
|
@@ -205,7 +209,6 @@ files:
|
|
205
209
|
- CHANGELOG.md
|
206
210
|
- CODE_OF_CONDUCT.md
|
207
211
|
- Gemfile
|
208
|
-
- Gemfile.lock
|
209
212
|
- LICENSE.txt
|
210
213
|
- README.md
|
211
214
|
- Rakefile
|
@@ -218,10 +221,15 @@ files:
|
|
218
221
|
- lib/rails_failover/active_record/middleware.rb
|
219
222
|
- lib/rails_failover/active_record/railtie.rb
|
220
223
|
- lib/rails_failover/redis.rb
|
221
|
-
- lib/rails_failover/redis/connector.rb
|
222
|
-
- lib/rails_failover/redis/handler.rb
|
224
|
+
- lib/rails_failover/redis/compat_4x/connector.rb
|
225
|
+
- lib/rails_failover/redis/compat_4x/handler.rb
|
226
|
+
- lib/rails_failover/redis/compat_4x/patches/client.rb
|
227
|
+
- lib/rails_failover/redis/compat_5x/client.rb
|
228
|
+
- lib/rails_failover/redis/compat_5x/config.rb
|
229
|
+
- lib/rails_failover/redis/compat_5x/handler.rb
|
230
|
+
- lib/rails_failover/redis/compat_5x/patches/client.rb
|
231
|
+
- lib/rails_failover/redis/handler_base.rb
|
223
232
|
- lib/rails_failover/version.rb
|
224
|
-
- lib/redis/patches/client.rb
|
225
233
|
- makefile
|
226
234
|
- postgresql.mk
|
227
235
|
- rails_failover.gemspec
|
@@ -230,7 +238,6 @@ homepage: https://github.com/discourse/rails_failover
|
|
230
238
|
licenses:
|
231
239
|
- MIT
|
232
240
|
metadata: {}
|
233
|
-
post_install_message:
|
234
241
|
rdoc_options: []
|
235
242
|
require_paths:
|
236
243
|
- lib
|
@@ -245,8 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
252
|
- !ruby/object:Gem::Version
|
246
253
|
version: '0'
|
247
254
|
requirements: []
|
248
|
-
rubygems_version: 3.
|
249
|
-
signing_key:
|
255
|
+
rubygems_version: 3.6.7
|
250
256
|
specification_version: 4
|
251
257
|
summary: Failover for ActiveRecord and Redis
|
252
258
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,205 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rails_failover (2.1.1)
|
5
|
-
activerecord (>= 6.1, < 8.0)
|
6
|
-
concurrent-ruby
|
7
|
-
railties (>= 6.1, < 8.0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
actionpack (7.1.3.4)
|
13
|
-
actionview (= 7.1.3.4)
|
14
|
-
activesupport (= 7.1.3.4)
|
15
|
-
nokogiri (>= 1.8.5)
|
16
|
-
racc
|
17
|
-
rack (>= 2.2.4)
|
18
|
-
rack-session (>= 1.0.1)
|
19
|
-
rack-test (>= 0.6.3)
|
20
|
-
rails-dom-testing (~> 2.2)
|
21
|
-
rails-html-sanitizer (~> 1.6)
|
22
|
-
actionview (7.1.3.4)
|
23
|
-
activesupport (= 7.1.3.4)
|
24
|
-
builder (~> 3.1)
|
25
|
-
erubi (~> 1.11)
|
26
|
-
rails-dom-testing (~> 2.2)
|
27
|
-
rails-html-sanitizer (~> 1.6)
|
28
|
-
activemodel (7.1.3.4)
|
29
|
-
activesupport (= 7.1.3.4)
|
30
|
-
activerecord (7.1.3.4)
|
31
|
-
activemodel (= 7.1.3.4)
|
32
|
-
activesupport (= 7.1.3.4)
|
33
|
-
timeout (>= 0.4.0)
|
34
|
-
activesupport (7.1.3.4)
|
35
|
-
base64
|
36
|
-
bigdecimal
|
37
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
38
|
-
connection_pool (>= 2.2.5)
|
39
|
-
drb
|
40
|
-
i18n (>= 1.6, < 2)
|
41
|
-
minitest (>= 5.1)
|
42
|
-
mutex_m
|
43
|
-
tzinfo (~> 2.0)
|
44
|
-
ast (2.4.2)
|
45
|
-
base64 (0.2.0)
|
46
|
-
bigdecimal (3.1.8)
|
47
|
-
builder (3.3.0)
|
48
|
-
byebug (11.1.3)
|
49
|
-
concurrent-ruby (1.3.3)
|
50
|
-
connection_pool (2.4.1)
|
51
|
-
crass (1.0.6)
|
52
|
-
diff-lcs (1.5.1)
|
53
|
-
drb (2.2.1)
|
54
|
-
erubi (1.13.0)
|
55
|
-
i18n (1.14.5)
|
56
|
-
concurrent-ruby (~> 1.0)
|
57
|
-
io-console (0.7.2)
|
58
|
-
irb (1.13.2)
|
59
|
-
rdoc (>= 4.0.0)
|
60
|
-
reline (>= 0.4.2)
|
61
|
-
json (2.7.2)
|
62
|
-
language_server-protocol (3.17.0.3)
|
63
|
-
loofah (2.22.0)
|
64
|
-
crass (~> 1.0.2)
|
65
|
-
nokogiri (>= 1.12.0)
|
66
|
-
minitest (5.24.1)
|
67
|
-
mutex_m (0.2.0)
|
68
|
-
nokogiri (1.16.6-aarch64-linux)
|
69
|
-
racc (~> 1.4)
|
70
|
-
nokogiri (1.16.6-arm-linux)
|
71
|
-
racc (~> 1.4)
|
72
|
-
nokogiri (1.16.6-arm64-darwin)
|
73
|
-
racc (~> 1.4)
|
74
|
-
nokogiri (1.16.6-x86-linux)
|
75
|
-
racc (~> 1.4)
|
76
|
-
nokogiri (1.16.6-x86_64-darwin)
|
77
|
-
racc (~> 1.4)
|
78
|
-
nokogiri (1.16.6-x86_64-linux)
|
79
|
-
racc (~> 1.4)
|
80
|
-
parallel (1.25.1)
|
81
|
-
parser (3.3.3.0)
|
82
|
-
ast (~> 2.4.1)
|
83
|
-
racc
|
84
|
-
pg (1.5.6)
|
85
|
-
prettier_print (1.2.1)
|
86
|
-
psych (5.1.2)
|
87
|
-
stringio
|
88
|
-
racc (1.8.0)
|
89
|
-
rack (3.1.6)
|
90
|
-
rack-session (2.0.0)
|
91
|
-
rack (>= 3.0.0)
|
92
|
-
rack-test (2.1.0)
|
93
|
-
rack (>= 1.3)
|
94
|
-
rackup (2.1.0)
|
95
|
-
rack (>= 3)
|
96
|
-
webrick (~> 1.8)
|
97
|
-
rails-dom-testing (2.2.0)
|
98
|
-
activesupport (>= 5.0.0)
|
99
|
-
minitest
|
100
|
-
nokogiri (>= 1.6)
|
101
|
-
rails-html-sanitizer (1.6.0)
|
102
|
-
loofah (~> 2.21)
|
103
|
-
nokogiri (~> 1.14)
|
104
|
-
railties (7.1.3.4)
|
105
|
-
actionpack (= 7.1.3.4)
|
106
|
-
activesupport (= 7.1.3.4)
|
107
|
-
irb
|
108
|
-
rackup (>= 1.0.0)
|
109
|
-
rake (>= 12.2)
|
110
|
-
thor (~> 1.0, >= 1.2.2)
|
111
|
-
zeitwerk (~> 2.6)
|
112
|
-
rainbow (3.1.1)
|
113
|
-
rake (13.2.1)
|
114
|
-
rdoc (6.7.0)
|
115
|
-
psych (>= 4.0.0)
|
116
|
-
redis (4.8.1)
|
117
|
-
regexp_parser (2.9.2)
|
118
|
-
reline (0.5.9)
|
119
|
-
io-console (~> 0.5)
|
120
|
-
rexml (3.3.1)
|
121
|
-
strscan
|
122
|
-
rspec (3.13.0)
|
123
|
-
rspec-core (~> 3.13.0)
|
124
|
-
rspec-expectations (~> 3.13.0)
|
125
|
-
rspec-mocks (~> 3.13.0)
|
126
|
-
rspec-core (3.13.0)
|
127
|
-
rspec-support (~> 3.13.0)
|
128
|
-
rspec-expectations (3.13.1)
|
129
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
130
|
-
rspec-support (~> 3.13.0)
|
131
|
-
rspec-mocks (3.13.1)
|
132
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
133
|
-
rspec-support (~> 3.13.0)
|
134
|
-
rspec-support (3.13.1)
|
135
|
-
rubocop (1.64.1)
|
136
|
-
json (~> 2.3)
|
137
|
-
language_server-protocol (>= 3.17.0)
|
138
|
-
parallel (~> 1.10)
|
139
|
-
parser (>= 3.3.0.2)
|
140
|
-
rainbow (>= 2.2.2, < 4.0)
|
141
|
-
regexp_parser (>= 1.8, < 3.0)
|
142
|
-
rexml (>= 3.2.5, < 4.0)
|
143
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
144
|
-
ruby-progressbar (~> 1.7)
|
145
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
146
|
-
rubocop-ast (1.31.3)
|
147
|
-
parser (>= 3.3.1.0)
|
148
|
-
rubocop-capybara (2.21.0)
|
149
|
-
rubocop (~> 1.41)
|
150
|
-
rubocop-discourse (3.8.1)
|
151
|
-
activesupport (>= 6.1)
|
152
|
-
rubocop (>= 1.59.0)
|
153
|
-
rubocop-capybara (>= 2.0.0)
|
154
|
-
rubocop-factory_bot (>= 2.0.0)
|
155
|
-
rubocop-rails (>= 2.25.0)
|
156
|
-
rubocop-rspec (>= 3.0.1)
|
157
|
-
rubocop-rspec_rails (>= 2.30.0)
|
158
|
-
rubocop-factory_bot (2.26.1)
|
159
|
-
rubocop (~> 1.61)
|
160
|
-
rubocop-rails (2.25.1)
|
161
|
-
activesupport (>= 4.2.0)
|
162
|
-
rack (>= 1.1)
|
163
|
-
rubocop (>= 1.33.0, < 2.0)
|
164
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
165
|
-
rubocop-rspec (3.0.2)
|
166
|
-
rubocop (~> 1.61)
|
167
|
-
rubocop-rspec_rails (2.30.0)
|
168
|
-
rubocop (~> 1.61)
|
169
|
-
rubocop-rspec (~> 3, >= 3.0.1)
|
170
|
-
ruby-progressbar (1.13.0)
|
171
|
-
stringio (3.1.1)
|
172
|
-
strscan (3.1.0)
|
173
|
-
syntax_tree (6.2.0)
|
174
|
-
prettier_print (>= 1.2.0)
|
175
|
-
syntax_tree-disable_ternary (1.0.0)
|
176
|
-
thor (1.3.1)
|
177
|
-
timeout (0.4.1)
|
178
|
-
tzinfo (2.0.6)
|
179
|
-
concurrent-ruby (~> 1.0)
|
180
|
-
unicode-display_width (2.5.0)
|
181
|
-
webrick (1.8.1)
|
182
|
-
zeitwerk (2.6.16)
|
183
|
-
|
184
|
-
PLATFORMS
|
185
|
-
aarch64-linux
|
186
|
-
arm-linux
|
187
|
-
arm64-darwin
|
188
|
-
x86-linux
|
189
|
-
x86_64-darwin
|
190
|
-
x86_64-linux
|
191
|
-
|
192
|
-
DEPENDENCIES
|
193
|
-
byebug
|
194
|
-
pg
|
195
|
-
rack
|
196
|
-
rails_failover!
|
197
|
-
rake
|
198
|
-
redis (~> 4.1)
|
199
|
-
rspec
|
200
|
-
rubocop-discourse
|
201
|
-
syntax_tree
|
202
|
-
syntax_tree-disable_ternary
|
203
|
-
|
204
|
-
BUNDLED WITH
|
205
|
-
2.5.11
|