health-monitor-rails 0.0.19 → 0.1.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 +4 -4
- data/app/controllers/health_monitor/health_controller.rb +1 -1
- data/lib/health_monitor/monitor.rb +2 -2
- data/lib/health_monitor/providers/base.rb +16 -0
- data/lib/health_monitor/providers/cache.rb +11 -3
- data/lib/health_monitor/providers/database.rb +3 -1
- data/lib/health_monitor/providers/redis.rb +10 -3
- data/lib/health_monitor/providers/resque.rb +2 -1
- data/lib/health_monitor/providers/sidekiq.rb +2 -1
- data/lib/health_monitor/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30793122295e562eb958e0d584ca7c554092af4c
|
4
|
+
data.tar.gz: 90982b94a76c8bd353b0a16619d67ee1315a5329
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b954f90b79b405c5cf37184dee94c23fe7c2849c72cdae075bac85bf53c76ba8f6dbad1d815e1c1f04ccdba5861fe88ba46a2e72309031bbe6e7c4af5ce12576
|
7
|
+
data.tar.gz: fcfe2fe1ee6dc1ef8776e69dbda09a63abc34e79a2380161ff9b5e2922a1ec67433c3a0b5e8f309694c7bc8cfad16798162ca24886fbe014bfa50190a0324547
|
@@ -11,11 +11,11 @@ module HealthMonitor
|
|
11
11
|
yield configuration if block_given?
|
12
12
|
end
|
13
13
|
|
14
|
-
def check!
|
14
|
+
def check!(request: nil)
|
15
15
|
configuration.providers.each do |provider|
|
16
16
|
require "health_monitor/providers/#{provider}"
|
17
17
|
|
18
|
-
monitor = "HealthMonitor::Providers::#{provider.capitalize}".constantize.new
|
18
|
+
monitor = "HealthMonitor::Providers::#{provider.capitalize}".constantize.new(request: request)
|
19
19
|
monitor.check!
|
20
20
|
end
|
21
21
|
rescue Exception => e
|
@@ -1,18 +1,26 @@
|
|
1
|
+
require 'health_monitor/providers/base'
|
2
|
+
|
1
3
|
module HealthMonitor
|
2
4
|
module Providers
|
3
5
|
class CacheException < StandardError; end
|
4
6
|
|
5
|
-
class Cache
|
7
|
+
class Cache < Base
|
6
8
|
def check!
|
7
9
|
time = Time.now.to_s
|
8
10
|
|
9
|
-
Rails.cache.write(
|
10
|
-
fetched = Rails.cache.read(
|
11
|
+
Rails.cache.write(key, time)
|
12
|
+
fetched = Rails.cache.read(key)
|
11
13
|
|
12
14
|
raise "different values (now: #{time}, fetched: #{fetched}" if fetched != time
|
13
15
|
rescue Exception => e
|
14
16
|
raise CacheException.new(e.message)
|
15
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def key
|
22
|
+
@key ||= ['health', request.try(:remote_ip)].join('_')
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'health_monitor/providers/base'
|
2
|
+
|
1
3
|
module HealthMonitor
|
2
4
|
module Providers
|
3
5
|
class DatabaseException < StandardError; end
|
4
6
|
|
5
|
-
class Database
|
7
|
+
class Database < Base
|
6
8
|
def check!
|
7
9
|
# Check connection to the DB:
|
8
10
|
ActiveRecord::Migrator.current_version
|
@@ -1,21 +1,28 @@
|
|
1
|
+
require 'health_monitor/providers/base'
|
1
2
|
require 'redis/namespace'
|
2
3
|
|
3
4
|
module HealthMonitor
|
4
5
|
module Providers
|
5
6
|
class RedisException < StandardError; end
|
6
7
|
|
7
|
-
class Redis
|
8
|
+
class Redis < Base
|
8
9
|
def check!
|
9
10
|
time = Time.now.to_s(:db)
|
10
11
|
|
11
12
|
r = ::Redis.new
|
12
|
-
r.set(
|
13
|
-
fetched = r.get(
|
13
|
+
r.set(key, time)
|
14
|
+
fetched = r.get(key)
|
14
15
|
|
15
16
|
raise "different values (now: #{time}, fetched: #{fetched}" if fetched != time
|
16
17
|
rescue => e
|
17
18
|
raise RedisException.new(e.message)
|
18
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def key
|
24
|
+
@key ||= ['health', request.try(:remote_ip)].join('_')
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
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: 0.0
|
4
|
+
version: 0.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: 2014-
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/health_monitor/configuration.rb
|
181
181
|
- lib/health_monitor/engine.rb
|
182
182
|
- lib/health_monitor/monitor.rb
|
183
|
+
- lib/health_monitor/providers/base.rb
|
183
184
|
- lib/health_monitor/providers/cache.rb
|
184
185
|
- lib/health_monitor/providers/database.rb
|
185
186
|
- lib/health_monitor/providers/redis.rb
|