activerecord-health 0.2.0 → 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: c72d2a420a64a52fd3cf223bafb4e84e4dab50b5fa807b512a322a8dc909f62d
4
- data.tar.gz: 98962aa4a2527386c888791d9b123967a004175305f985068e475b4f8557e653
3
+ metadata.gz: 348dbee0dbd08b32c2938cfa70e72ec31c6cdb4a6c83923636ffc89015afefe6
4
+ data.tar.gz: 3c71fecb5c3b8fc5a028c1976638429f06dc79920566f63be49a173a476ffbd8
5
5
  SHA512:
6
- metadata.gz: c816d187880de866ee3e48fd972ea3b80543bfeba86d4a16466279a0bb45ae776f976f16f7d39dbdb68dd422f1f3fe0d92b8bf4ba2269e6c462ce6a85337b3c3
7
- data.tar.gz: 291b81fb5116df82c6b310d17e7077701648e16b9eacf24cd57447f60bda87e8e0483d13b4cc3b92ba772d878566bf11a098a2a32e4bb80a84e5a357139c596c
6
+ metadata.gz: 05d387d64f3d76155c3585c80fbbcd25f0d2d4988127d483624707af2f48e18159d246aafdf7455f5029b12e5c07decd4eec7b8a704df365ab3af2ac157c8d24
7
+ data.tar.gz: 1c64ca6bc0a3d618d6463cde6ad2f050966893431a95b092c1f581d80729f4acef7fc53fb0e05176def34a409005bd6fe0327be6db774d6c9309301a47ab6ea7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
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
+
11
+ ## 0.2.1
12
+
13
+ ### Bug Fixes
14
+
15
+ - Fix file permissions causing LoadError in Docker containers (#6)
16
+
3
17
  ## 0.2.0
4
18
 
5
19
  ### 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 |
data/Rakefile CHANGED
@@ -22,4 +22,26 @@ Rake::TestTask.new(:test_all) do |t|
22
22
  t.test_files = FileList["test/**/*_test.rb"]
23
23
  end
24
24
 
25
- task default: %i[test standard]
25
+ task :check_permissions do
26
+ spec = Gem::Specification.load("activerecord-health.gemspec")
27
+ files = spec.files.select { |path| File.file?(path) }
28
+
29
+ unreadable = files.filter_map do |path|
30
+ mode = File.stat(path).mode & 0o777
31
+ next if (mode & 0o004) != 0
32
+
33
+ "#{path} (#{format("%o", mode)})"
34
+ end
35
+
36
+ if unreadable.any?
37
+ warn "Non-world-readable files detected:"
38
+ unreadable.sort.each { |entry| warn " - #{entry}" }
39
+ abort "Fix permissions (chmod o+r) before release."
40
+ end
41
+ end
42
+
43
+ task default: %i[test standard check_permissions]
44
+
45
+ if Rake::Task.task_defined?("release")
46
+ Rake::Task["release"].enhance(%i[default])
47
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Activerecord
4
4
  module Health
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
@@ -92,8 +92,8 @@ module ActiveRecord
92
92
 
93
93
  def adapter_class_for(connection)
94
94
  case connection.adapter_name.downcase
95
- when /postgresql/ then Adapters::PostgreSQLAdapter
96
- when /mysql/ then Adapters::MySQLAdapter
95
+ when /postgresql/, /postgis/ then Adapters::PostgreSQLAdapter
96
+ when /mysql/, /trilogy/ then Adapters::MySQLAdapter
97
97
  else raise "Unsupported database adapter: #{connection.adapter_name}"
98
98
  end
99
99
  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.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: 3.6.9
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: []