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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec92d63c0e305e0db39997e07711a0a24471baf7
4
- data.tar.gz: 7af36ecdf6f4f876c55e6c9141e149041dab3017
3
+ metadata.gz: a3f053420e3858137ef87df2691280d2318b2891
4
+ data.tar.gz: 8818c385be1a0824c8c16c777b4749fbbc0c408e
5
5
  SHA512:
6
- metadata.gz: 59abe49e4f5ee482268a85d76f3d636b5fe1e74a395da89485bf2e23ac68df4aea8713759a10b0305b4647616feb49e972750920f2f3f6267f0d68103705becc
7
- data.tar.gz: fd84788912d20dbae1ba18b59310d003b602194649ae406ff688f0ac3565e9c3c834b271b571b9fe9af4d2e9faef43f00afd93bbc62b2dcabf0742eb5090812e
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 |provider|
13
- define_method provider do |&block|
14
- require "health_monitor/providers/#{provider}"
12
+ PROVIDERS.each do |provider_name|
13
+ define_method provider_name do |&block|
14
+ require "health_monitor/providers/#{provider_name}"
15
15
 
16
- (@providers ||= Set.new) << provider
16
+ add_provider("HealthMonitor::Providers::#{provider_name.capitalize}".constantize)
17
+ end
18
+ end
17
19
 
18
- "HealthMonitor::Providers::#{provider.capitalize}".constantize
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 = "HealthMonitor::Providers::#{provider.capitalize}".constantize.new(request: request)
16
+ monitor = provider.new(request: request)
17
17
  monitor.check!
18
18
  end
19
19
  rescue Exception => e
@@ -1,3 +1,3 @@
1
1
  module HealthMonitor
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  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: 2.0.2
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-10 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails