rails_failover 0.8.0 → 0.8.1

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: 146164de9729fe33317969e8d3ca2c5c79980e947f93dfd32b6673a1a95061a6
4
- data.tar.gz: d3e6eb2cee6bcf663115e72c9e62d62e3f869753549fdcff55381ca4405842c1
3
+ metadata.gz: 9b0f3e010743d83bd67b2cce785fde0952ba32c82c8c1ab5fef3aa56e5baa520
4
+ data.tar.gz: 26cc2466069dfe48b691d8676078b3ed9ee3ce82e7a8d4447fa327436741fd39
5
5
  SHA512:
6
- metadata.gz: 1554851137a5251f524574f7d0120924910ad3dc755ad336e9c29c7404cf515d79dad9cb538f06b4084363d919f37586f412f5702fb92a2c85678bd161349fd3
7
- data.tar.gz: 0f2a72692577a2be3d961da51be3ba150b7e7311fbe2932b062443d2a10dba6014e04268be105a815ab08169b542aa0d3a26dbe36611f036eecdc7a17bb527ac
6
+ metadata.gz: 5ce28a0d758dde383537bce455502edfcbf9388ad4c2835edc17b2e259156affc885153f728e39fa66c8c25d3f9dfea34a8f489b663e7738fc092dc6c76dccb8
7
+ data.tar.gz: 0f0c08446e0e64c5eb6ee972e80e8776e58fbd32877254e50098a17a4d4475db64379d7ad237933b054e5eaf7c54df72785c69253e7d31be1b28d38028fcaf11
data/README.md CHANGED
@@ -53,7 +53,7 @@ end
53
53
 
54
54
  #### Multiple connection handlers
55
55
 
56
- Note: This API is unstable and is likely to changes when Rails 6.1 is released with sharding support.
56
+ Note: This API is unstable and is likely to change when Rails 6.1 is released with sharding support.
57
57
 
58
58
  ```
59
59
  # config/database.yml
@@ -169,7 +169,7 @@ module RailsFailover
169
169
  # Calling .disconnect can cause a running subscribe() to block forever
170
170
  # Therefore try to acquire the lock
171
171
  def soft_disconnect(redis, client, role)
172
- has_lock = redis.mon_try_enter
172
+ has_lock = redis_mon_try_enter(redis)
173
173
 
174
174
  if !has_lock
175
175
  begin
@@ -180,7 +180,7 @@ module RailsFailover
180
180
 
181
181
  waiting_since = Process.clock_gettime(Process::CLOCK_MONOTONIC)
182
182
  loop do # Keep trying
183
- break if has_lock = redis.mon_try_enter
183
+ break if has_lock = redis_mon_try_enter(redis)
184
184
  break if !client.connection.connected? # Disconnected by other thread
185
185
  break if client.connection.rails_failover_role != role # Reconnected by other thread
186
186
  time_now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@@ -191,12 +191,28 @@ module RailsFailover
191
191
 
192
192
  client.disconnect if client.connection&.rails_failover_role == role
193
193
  ensure
194
- redis.mon_exit if has_lock
194
+ redis_mon_exit(redis) if has_lock
195
195
  end
196
196
 
197
197
  def logger
198
198
  RailsFailover::Redis.logger
199
199
  end
200
+
201
+ def redis_mon_try_enter(redis)
202
+ if redis.respond_to? :mon_try_enter
203
+ redis.mon_try_enter
204
+ else
205
+ redis.instance_variable_get(:@monitor).mon_try_enter
206
+ end
207
+ end
208
+
209
+ def redis_mon_exit(redis)
210
+ if redis.respond_to? :mon_exit
211
+ redis.mon_exit
212
+ else
213
+ redis.instance_variable_get(:@monitor).mon_exit
214
+ end
215
+ end
200
216
  end
201
217
  end
202
218
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsFailover
4
- VERSION = "0.8.0"
4
+ VERSION = "0.8.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_failover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Tan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-17 00:00:00.000000000 Z
11
+ date: 2022-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord