activerecord-health 0.2.1 → 0.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/CHANGELOG.md +8 -0
- data/README.md +1 -0
- data/lib/activerecord/health/version.rb +1 -1
- data/lib/activerecord/health.rb +1 -1
- data/test/unit/health_test.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 348dbee0dbd08b32c2938cfa70e72ec31c6cdb4a6c83923636ffc89015afefe6
|
|
4
|
+
data.tar.gz: 3c71fecb5c3b8fc5a028c1976638429f06dc79920566f63be49a173a476ffbd8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 05d387d64f3d76155c3585c80fbbcd25f0d2d4988127d483624707af2f48e18159d246aafdf7455f5029b12e5c07decd4eec7b8a704df365ab3af2ac157c8d24
|
|
7
|
+
data.tar.gz: 1c64ca6bc0a3d618d6463cde6ad2f050966893431a95b092c1f581d80729f4acef7fc53fb0e05176def34a409005bd6fe0327be6db774d6c9309301a47ab6ea7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/activerecord/health.rb
CHANGED
|
@@ -92,7 +92,7 @@ module ActiveRecord
|
|
|
92
92
|
|
|
93
93
|
def adapter_class_for(connection)
|
|
94
94
|
case connection.adapter_name.downcase
|
|
95
|
-
when /postgresql/ then Adapters::PostgreSQLAdapter
|
|
95
|
+
when /postgresql/, /postgis/ then Adapters::PostgreSQLAdapter
|
|
96
96
|
when /mysql/, /trilogy/ then Adapters::MySQLAdapter
|
|
97
97
|
else raise "Unsupported database adapter: #{connection.adapter_name}"
|
|
98
98
|
end
|
data/test/unit/health_test.rb
CHANGED
|
@@ -93,6 +93,20 @@ class HealthTest < ActiveRecord::Health::TestCase
|
|
|
93
93
|
assert_equal 0.5, cache.read("activerecord_health:load_pct:primary")
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
+
def test_load_pct_supports_postgis_adapter
|
|
97
|
+
cache = ActiveSupport::Cache::MemoryStore.new
|
|
98
|
+
|
|
99
|
+
ActiveRecord::Health.configure do |config|
|
|
100
|
+
config.vcpu_count = 16
|
|
101
|
+
config.cache = cache
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
connection = MockConnection.new(active_session_count: 4, adapter_name: "PostGIS")
|
|
105
|
+
mock_model = MockModel.new("primary", connection)
|
|
106
|
+
|
|
107
|
+
assert_equal 0.25, ActiveRecord::Health.load_pct(model: mock_model)
|
|
108
|
+
end
|
|
109
|
+
|
|
96
110
|
def test_load_pct_returns_1_0_when_database_query_fails
|
|
97
111
|
cache = ActiveSupport::Cache::MemoryStore.new
|
|
98
112
|
|
|
@@ -164,14 +178,13 @@ class MockModel
|
|
|
164
178
|
end
|
|
165
179
|
|
|
166
180
|
class MockConnection
|
|
167
|
-
def initialize(active_session_count: 0, should_fail: false)
|
|
181
|
+
def initialize(active_session_count: 0, should_fail: false, adapter_name: "PostgreSQL")
|
|
168
182
|
@active_session_count = active_session_count
|
|
169
183
|
@should_fail = should_fail
|
|
184
|
+
@adapter_name = adapter_name
|
|
170
185
|
end
|
|
171
186
|
|
|
172
|
-
|
|
173
|
-
"PostgreSQL"
|
|
174
|
-
end
|
|
187
|
+
attr_reader :adapter_name
|
|
175
188
|
|
|
176
189
|
def select_value(query)
|
|
177
190
|
raise "Connection failed" if @should_fail
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-health
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nate Berkopec
|
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
98
98
|
- !ruby/object:Gem::Version
|
|
99
99
|
version: '0'
|
|
100
100
|
requirements: []
|
|
101
|
-
rubygems_version: 4.0.
|
|
101
|
+
rubygems_version: 4.0.10
|
|
102
102
|
specification_version: 4
|
|
103
103
|
summary: Database health monitoring for ActiveRecord with automatic load shedding
|
|
104
104
|
test_files: []
|