resilient_reads 0.1.1 → 0.1.2
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/lib/resilient_reads/lag_checker.rb +7 -7
- data/lib/resilient_reads/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9ca59bd308356c26b2f833ae03fff90e58733e58e1c972c2eed7f84997e1f72
|
|
4
|
+
data.tar.gz: bb1eeee56723a1856ec9204b8cd3a8e521fc332d8ab26b0a3c68a538910726b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c443fc6041771447152fbf30c42df9e6aabfbd1a626da0454a102d320c52c2da687e6d9ee196e9caf03a35057de7eb91e1233b785c474c3dc14034962b15b4b1
|
|
7
|
+
data.tar.gz: 59acea745a3fc0e690607fca23f39e342ccf8a1350a813267336f16491609ea16e10d7fb5739278a45abcd888718a5f0352e760e59c414bc16fcf7f730fafca6
|
|
@@ -45,9 +45,8 @@ module ResilientReads
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def self.lag_for_mysql(conn)
|
|
48
|
-
result = conn.execute("SHOW
|
|
48
|
+
result = conn.execute("SHOW REPLICA STATUS")
|
|
49
49
|
# MySQL 8.0.22+ uses SHOW REPLICA STATUS
|
|
50
|
-
result = conn.execute("SHOW REPLICA STATUS") if result.respond_to?(:count) && result.count == 0
|
|
51
50
|
|
|
52
51
|
row = if result.respond_to?(:first)
|
|
53
52
|
result.first
|
|
@@ -58,11 +57,12 @@ module ResilientReads
|
|
|
58
57
|
return nil unless row
|
|
59
58
|
|
|
60
59
|
# Seconds_Behind_Master / Seconds_Behind_Source (MySQL 8.0.22+)
|
|
61
|
-
lag =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
lag =
|
|
61
|
+
if row.is_a?(Hash)
|
|
62
|
+
row["Seconds_Behind_Source"]
|
|
63
|
+
elsif row.respond_to?(:[])
|
|
64
|
+
row["Seconds_Behind_Source"]
|
|
65
|
+
end
|
|
66
66
|
|
|
67
67
|
lag&.to_f
|
|
68
68
|
rescue => e
|