health-monitor-rails 12.2.0 → 12.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/health_monitor/providers/solr.rb +32 -6
- data/lib/health_monitor/version.rb +1 -1
- 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: 952a62b089d3b56df2b8ab11b329dae2512d285db4027bde6705892e171ff755
|
4
|
+
data.tar.gz: 36a7996a83a871a82814caef5d31d2cc880b1f40bd12e2f191290e72a9d1537f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9878debcd730c9848ec50af8ed0b1ed912adffc240c1aab657c82a40e0113ac32a335f53ef32c9c7a3487eee68483235b767009e900c376eb1df55dd28cf2cd
|
7
|
+
data.tar.gz: d361fd7cf5fe894de0d2bce196b06c23f9c3015d1dfa545ba0158c441e2c4f1caed1d6053975a9ff545082025ec1a1c387644a7aaa4dbede0e020c8869289cac
|
data/README.md
CHANGED
@@ -316,6 +316,7 @@ Please note that `url` or `connection` can't be used at the same time.
|
|
316
316
|
### Solr
|
317
317
|
|
318
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
|
+
* `collection`: An optional parameter used to connect to your specific Solr collection - must be a string. By setting this parameter the code will check the status of this individual collection in your Solr instance instead of just the status of the overall Solr instance
|
319
320
|
|
320
321
|
### Adding a Custom Provider
|
321
322
|
|
@@ -9,12 +9,14 @@ module HealthMonitor
|
|
9
9
|
class Solr < Base
|
10
10
|
class Configuration < Base::Configuration
|
11
11
|
DEFAULT_URL = nil
|
12
|
-
|
12
|
+
DEFAULT_COLLECTION = nil
|
13
|
+
attr_accessor :url, :collection
|
13
14
|
|
14
15
|
def initialize(provider)
|
15
16
|
super(provider)
|
16
17
|
|
17
18
|
@url = DEFAULT_URL
|
19
|
+
@collection = DEFAULT_COLLECTION
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -31,6 +33,22 @@ module HealthMonitor
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def check_solr_connection!
|
36
|
+
if configuration.collection
|
37
|
+
check_solr_collection!
|
38
|
+
else
|
39
|
+
check_solr_uri!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_solr_collection!
|
44
|
+
response = solr_response(uri: collection_uri)
|
45
|
+
json = JSON.parse(response.body) if response.code == '200'
|
46
|
+
return if response.is_a?(Net::HTTPSuccess) && json['status'].casecmp?('OK')
|
47
|
+
|
48
|
+
raise "The Solr collection has an invalid status #{collection_uri}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def check_solr_uri!
|
34
52
|
json = JSON.parse(solr_response.body)
|
35
53
|
raise "The solr has an invalid status #{status_uri}" if json['responseHeader']['status'] != 0
|
36
54
|
end
|
@@ -44,16 +62,24 @@ module HealthMonitor
|
|
44
62
|
end
|
45
63
|
end
|
46
64
|
|
47
|
-
def
|
65
|
+
def collection_uri
|
66
|
+
@collection_uri ||= begin
|
67
|
+
uri = URI(configuration.url)
|
68
|
+
uri.path = "/solr/#{configuration.collection}/admin/ping"
|
69
|
+
uri
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def solr_request(uri: status_uri)
|
48
74
|
@solr_request ||= begin
|
49
|
-
req = Net::HTTP::Get.new(
|
50
|
-
req.basic_auth(
|
75
|
+
req = Net::HTTP::Get.new(uri)
|
76
|
+
req.basic_auth(uri.user, uri.password) if uri.user && uri.password
|
51
77
|
req
|
52
78
|
end
|
53
79
|
end
|
54
80
|
|
55
|
-
def solr_response
|
56
|
-
Net::HTTP.start(status_uri.hostname, status_uri.port) { |http| http.request(solr_request) }
|
81
|
+
def solr_response(uri: status_uri)
|
82
|
+
Net::HTTP.start(status_uri.hostname, status_uri.port) { |http| http.request(solr_request(uri: uri)) }
|
57
83
|
end
|
58
84
|
end
|
59
85
|
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.
|
4
|
+
version: 12.3.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-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|