janus-ar 0.4.0 → 0.5.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/.gitignore +1 -0
- data/.rubocop.yml +4 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/active_record/connection_adapters/janus_mysql2_adapter.rb +7 -5
- data/lib/janus/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c98a42deb00198b9715f86f8bee613e885c046be1b6f7ece50d64c1493227b90
|
|
4
|
+
data.tar.gz: 2db888f02a4b707fcb9e75dc90c86aefff19f6ace5ee2a33a38c6dadc6b14ec9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53fdd8901b56a41a1ae2e10549fe3c87a2a1d96bb14923c5879bebe5223f81853582e941483488c8076d1cae3612a5be666df14698276ce6760294a6d9bcd9cd
|
|
7
|
+
data.tar.gz: 2a50f4a05ffbded2bb3bb15ab7e692251ee9daefc42d27029cb86a355d1c9321e2739c6410362b19df270c33caa4ad8357ba7c18ff4cdbc11ad81c51b85b8f05
|
data/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
janus-ar-*.gem
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -30,7 +30,6 @@ module ActiveRecord
|
|
|
30
30
|
|
|
31
31
|
@replica_config = args[0][:janus]['replica']
|
|
32
32
|
args[0] = args[0][:janus]['primary']
|
|
33
|
-
|
|
34
33
|
super(*args)
|
|
35
34
|
@connection_parameters ||= args[0]
|
|
36
35
|
update_config
|
|
@@ -89,11 +88,14 @@ module ActiveRecord
|
|
|
89
88
|
end
|
|
90
89
|
|
|
91
90
|
def can_go_to_replica?(sql)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
SQL_PRIMARY_MATCHERS.any? { |matcher| sql =~ matcher }
|
|
91
|
+
!should_go_to_primary?(sql)
|
|
92
|
+
end
|
|
95
93
|
|
|
96
|
-
|
|
94
|
+
def should_go_to_primary?(sql)
|
|
95
|
+
Janus::Context.use_primary? ||
|
|
96
|
+
write_query?(sql) ||
|
|
97
|
+
open_transactions.positive? ||
|
|
98
|
+
SQL_PRIMARY_MATCHERS.any? { |matcher| sql =~ matcher }
|
|
97
99
|
end
|
|
98
100
|
|
|
99
101
|
def send_to_replica(sql, connection: nil, method: :exec_query)
|
data/lib/janus/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: janus-ar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lloyd Watkin
|
|
@@ -117,6 +117,7 @@ extra_rdoc_files: []
|
|
|
117
117
|
files:
|
|
118
118
|
- ".github/dependabot.yml"
|
|
119
119
|
- ".github/workflows/ci.yml"
|
|
120
|
+
- ".gitignore"
|
|
120
121
|
- ".rspec"
|
|
121
122
|
- ".rubocop.yml"
|
|
122
123
|
- CODE_OF_CONDUCT.md
|