health-monitor-rails 12.1.0 → 12.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a4b35be2c84bd3859456f041a978da8828cb72294d86bfab7b97dc3478134b3
4
- data.tar.gz: a393dbc7c46777aae939589d443b67ef41abbeb238879adf4ff6985511aceda9
3
+ metadata.gz: 5b598be966486e38fe823322c1f067e033543ad2df2eb3175c4f48464fd486c0
4
+ data.tar.gz: c75ceeeffb9d18b5427d2791359a74616b91e830fce1cafd7f737e78b7b87c23
5
5
  SHA512:
6
- metadata.gz: 1f18d57cdf6471cf63e7ad493b4019bf1a5edfca635393aa1f35def68439dfd859b19ccf2fb3f5ab178015db46b24bf7507ed43fbc8efc8114e44d7d7e8ff736
7
- data.tar.gz: 4da774036fbbf7e4baf0e6abb2bd7eb313282bc2ea3ca39feded6bfe0c099f2fe5549e02b799e255d9d4738d07bf80ecda5dfd2b10caa213f3f68170204d684d
6
+ metadata.gz: 54c82d499f5230ffb29d25d1f2ae07a82df5b2c31babfae8759c213488c88024beaa286f64adeaa63a932064e8f5d7496dc263136422b694ee130481c2a1fde4
7
+ data.tar.gz: 446c5607d7eb1f96803318cfca0c460147e45fce68ba0b243f52c91913211f3c1df98a5d0a8a087269ccecd45bf67f882955d46b658e954e9cd240bc0e16f284
data/README.md CHANGED
@@ -176,6 +176,7 @@ The following services are currently supported:
176
176
  * Sidekiq
177
177
  * Resque
178
178
  * Delayed Job
179
+ * Solr
179
180
 
180
181
  ## Configuration
181
182
 
@@ -312,6 +313,10 @@ Please note that `url` or `connection` can't be used at the same time.
312
313
 
313
314
  * `queue_size`: the size (maximum) of a queue which is considered unhealthy (the default is 100).
314
315
 
316
+ ### Solr
317
+
318
+ * `url`: the URL used to connect to your Solr instance - must be a string. You can also use `url` to explicitly configure authentication (e.g., `'https://user:pass@example.solr.com:8983/'`)
319
+
315
320
  ### Adding a Custom Provider
316
321
 
317
322
  It's also possible to add custom health check providers suited for your needs (of course, it's highly appreciated and encouraged if you'd contribute useful providers to the project).
@@ -434,6 +439,24 @@ nicolas@desktop:$ echo $?
434
439
  2
435
440
  ```
436
441
 
442
+ ## Development
443
+ In order to work on development on the gem itself
444
+
445
+ ### Installing the gems
446
+ Use the [appraisal gem](https://github.com/thoughtbot/appraisal) to install the bundles for different rails versions:
447
+
448
+ ```bash
449
+ appraisal clean
450
+ appraisal generate
451
+ appraisal install
452
+ ```
453
+
454
+ ### Running the tests
455
+ Use appraisal to run the tests using rake
456
+ ```bash
457
+ appraisal rake
458
+ ```
459
+
437
460
  ## License
438
461
 
439
462
  The MIT License (MIT)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module HealthMonitor
4
4
  class Configuration
5
- PROVIDERS = %i[cache database delayed_job redis resque sidekiq].freeze
5
+ PROVIDERS = %i[cache database delayed_job redis resque sidekiq solr].freeze
6
6
 
7
7
  attr_accessor :basic_auth_credentials,
8
8
  :environment_variables,
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'health_monitor/providers/base'
4
+
5
+ module HealthMonitor
6
+ module Providers
7
+ class SolrException < StandardError; end
8
+
9
+ class Solr < Base
10
+ class Configuration < Base::Configuration
11
+ DEFAULT_URL = nil
12
+ attr_accessor :url
13
+
14
+ def initialize(provider)
15
+ super(provider)
16
+
17
+ @url = DEFAULT_URL
18
+ end
19
+ end
20
+
21
+ def check!
22
+ check_solr_connection!
23
+ rescue Exception => e
24
+ raise SolrException.new(e.message)
25
+ end
26
+
27
+ private
28
+
29
+ def configuration_class
30
+ ::HealthMonitor::Providers::Solr::Configuration
31
+ end
32
+
33
+ def check_solr_connection!
34
+ json = JSON.parse(solr_response.body)
35
+ raise "The solr has an invalid status #{status_uri}" if json['responseHeader']['status'] != 0
36
+ end
37
+
38
+ def status_uri
39
+ @status_uri ||= begin
40
+ uri = URI(configuration.url)
41
+ uri.path = '/solr/admin/cores'
42
+ uri.query = 'action=STATUS'
43
+ uri
44
+ end
45
+ end
46
+
47
+ def solr_request
48
+ @solr_request ||= begin
49
+ req = Net::HTTP::Get.new(status_uri)
50
+ req.basic_auth(status_uri.user, status_uri.password) if status_uri.user && status_uri.password
51
+ req
52
+ end
53
+ end
54
+
55
+ def solr_response
56
+ Net::HTTP.start(status_uri.hostname, status_uri.port) { |http| http.request(solr_request) }
57
+ end
58
+ end
59
+ end
60
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HealthMonitor
4
- VERSION = '12.1.0'
4
+ VERSION = '12.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health-monitor-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.1.0
4
+ version: 12.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Beder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-29 00:00:00.000000000 Z
11
+ date: 2024-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -48,6 +48,7 @@ files:
48
48
  - lib/health_monitor/providers/redis.rb
49
49
  - lib/health_monitor/providers/resque.rb
50
50
  - lib/health_monitor/providers/sidekiq.rb
51
+ - lib/health_monitor/providers/solr.rb
51
52
  - lib/health_monitor/version.rb
52
53
  homepage: https://github.com/lbeder/health-monitor-rails
53
54
  licenses: