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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6c687a09ea6b1b5eba31b753d142fa31e2c058c8093c87f01128ee0feda6196
4
- data.tar.gz: 7c8a6ce6ac321b6f2dd552c1a30680ef2327b5739306282be0a7bb054c5425ec
3
+ metadata.gz: 348dbee0dbd08b32c2938cfa70e72ec31c6cdb4a6c83923636ffc89015afefe6
4
+ data.tar.gz: 3c71fecb5c3b8fc5a028c1976638429f06dc79920566f63be49a173a476ffbd8
5
5
  SHA512:
6
- metadata.gz: c592cfb07a93c8ef028d22bffd880537a51ede3b7362ba17e5a1d9bed56cbec03e806caebfbec39107408b8c7921fd6e364b8dc5aab0ebf62925e4e9533f79fc
7
- data.tar.gz: 77a6e47554826b7127a07a070d67e5d3259dd92360a98160c922efa8ed9dd4ed57b02649e3a892fb67aeb1eeceaf9a731cb0e8c60d073d800bdd207af2c7c404
6
+ metadata.gz: 05d387d64f3d76155c3585c80fbbcd25f0d2d4988127d483624707af2f48e18159d246aafdf7455f5029b12e5c07decd4eec7b8a704df365ab3af2ac157c8d24
7
+ data.tar.gz: 1c64ca6bc0a3d618d6463cde6ad2f050966893431a95b092c1f581d80729f4acef7fc53fb0e05176def34a409005bd6fe0327be6db774d6c9309301a47ab6ea7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.3.0
6
+
7
+ ### Bug Fixes
8
+
9
+ - Support the PostGIS adapter from activerecord-postgis-adapter.
10
+
3
11
  ## 0.2.1
4
12
 
5
13
  ### Bug Fixes
data/README.md CHANGED
@@ -183,6 +183,7 @@ end
183
183
  | Database | Supported |
184
184
  |----------|-----------|
185
185
  | PostgreSQL 10+ | Yes |
186
+ | PostGIS (via activerecord-postgis-adapter) | Yes |
186
187
  | MySQL 5.1+ | Yes |
187
188
  | MySQL 8.0.22+ | Yes (uses performance_schema) |
188
189
  | MariaDB | Yes |
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Activerecord
4
4
  module Health
5
- VERSION = "0.2.1"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
@@ -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
@@ -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
- def adapter_name
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.2.1
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.3
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: []