health-monitor-rails 2.0.2 → 2.1.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 +22 -0
- data/lib/health_monitor/configuration.rb +19 -5
- data/lib/health_monitor/monitor.rb +1 -1
- data/lib/health_monitor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3f053420e3858137ef87df2691280d2318b2891
|
4
|
+
data.tar.gz: 8818c385be1a0824c8c16c777b4749fbbc0c408e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd85c584edd784d4281c9d7aebc96d55bb442250f7eb284f1f8b5f495d381fd6ec8edbac4a6fb853409262e897cd3fad05b2570703817c180bac1707dd375609
|
7
|
+
data.tar.gz: 8ae3e62d1ee63dd849453f5799279b48f9b8f06fe8c69d7080bef9cdd9d3bc70b445e2b1bba93b2befa660270005d2a377f32213d8702b21716f9f79329acec1
|
data/README.md
CHANGED
@@ -75,6 +75,28 @@ The currently supported settings are:
|
|
75
75
|
|
76
76
|
* `latency`: the latency (in seconds) of a queue (now - when the oldest job was enqueued) which is considered unhealthy (the default is 30 seconds, but larger processing queue should have a larger latency value).
|
77
77
|
|
78
|
+
### Adding a custom provider
|
79
|
+
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).
|
80
|
+
|
81
|
+
In order to add a custom provider, you'd need to:
|
82
|
+
|
83
|
+
* Implement the `HealthMonitor::Providers::Base` class and its `check!` method (a check is considered as failed if it raises an exception):
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
class CustomProvider < HealthMonitor::Providers::Base
|
87
|
+
def check!
|
88
|
+
raise 'Oh oh!'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
```
|
92
|
+
* Add its class to the configuration:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
HealthMonitor.configure do |config|
|
96
|
+
config.add_custom_provider(CustomProvider)
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
78
100
|
### Adding a custom error callback
|
79
101
|
If you need to perform any additional error handling (for example, for additional error reporting), you can configure a custom error callback:
|
80
102
|
|
@@ -9,14 +9,28 @@ module HealthMonitor
|
|
9
9
|
database
|
10
10
|
end
|
11
11
|
|
12
|
-
PROVIDERS.each do |
|
13
|
-
define_method
|
14
|
-
require "health_monitor/providers/#{
|
12
|
+
PROVIDERS.each do |provider_name|
|
13
|
+
define_method provider_name do |&block|
|
14
|
+
require "health_monitor/providers/#{provider_name}"
|
15
15
|
|
16
|
-
(
|
16
|
+
add_provider("HealthMonitor::Providers::#{provider_name.capitalize}".constantize)
|
17
|
+
end
|
18
|
+
end
|
17
19
|
|
18
|
-
|
20
|
+
def add_custom_provider(custom_provider_class)
|
21
|
+
unless custom_provider_class < HealthMonitor::Providers::Base
|
22
|
+
raise ArgumentError.new('custom provider class must implement HealthMonitor::Providers::Base')
|
19
23
|
end
|
24
|
+
|
25
|
+
add_provider(custom_provider_class)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def add_provider(provider_class)
|
31
|
+
(@providers ||= Set.new) << provider_class
|
32
|
+
|
33
|
+
provider_class
|
20
34
|
end
|
21
35
|
end
|
22
36
|
end
|
@@ -13,7 +13,7 @@ module HealthMonitor
|
|
13
13
|
|
14
14
|
def check!(request: nil)
|
15
15
|
configuration.providers.each do |provider|
|
16
|
-
monitor =
|
16
|
+
monitor = provider.new(request: request)
|
17
17
|
monitor.check!
|
18
18
|
end
|
19
19
|
rescue Exception => e
|
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: 2.0
|
4
|
+
version: 2.1.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: 2015-04-
|
11
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|