resque-monitoring 0.0.2 → 0.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b20ecf9be0c45f0abf6fe82f48f69ae0441a07c
|
4
|
+
data.tar.gz: 673a2ffbb4a24f744a83c77b06391a5f7ca69cbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d96a0ec708bac72f629d83017dc621c6f5d95c7f0c6986ee685c2d02c5b1d875868b4db9df369cc3cde25685346ad749ac25429910e297bb1062f4f2d4ceaaff
|
7
|
+
data.tar.gz: 51c4fa58a8bc6f90d9067260b1f4cd8a94087948b8f75c99f14b816cd936d08362a2d853084713644ef1a64e02158a3264fd9688acb48bd8a7a507ab1e95081d
|
data/lib/resque/monitoring.rb
CHANGED
@@ -15,20 +15,34 @@ module Resque
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def status
|
18
|
-
|
19
|
-
|
18
|
+
last_execution_date = last_execution.date
|
19
|
+
return not_executed_yet unless last_execution_date.present?
|
20
|
+
return Status.ok if assert.call(last_execution_date)
|
21
|
+
executed_long_time_ago(last_execution_date)
|
20
22
|
end
|
21
23
|
|
22
24
|
private
|
25
|
+
def not_executed_yet
|
26
|
+
Status.error('not executed yet')
|
27
|
+
end
|
28
|
+
|
29
|
+
def executed_long_time_ago(last_execution_date)
|
30
|
+
Status.error("executed a long time ago, last execution: #{last_execution_date}")
|
31
|
+
end
|
32
|
+
|
23
33
|
def assert
|
24
|
-
@assert ||=
|
25
|
-
last_execution >= DateTime.now - 15.minutes
|
26
|
-
end
|
34
|
+
@assert ||= default_assert
|
27
35
|
end
|
28
36
|
|
29
37
|
def last_execution
|
30
38
|
@last_execution ||= LastExecution.by(name)
|
31
39
|
end
|
40
|
+
|
41
|
+
def default_assert
|
42
|
+
Proc.new do |last_execution|
|
43
|
+
last_execution >= DateTime.now - 15.minutes
|
44
|
+
end
|
45
|
+
end
|
32
46
|
end
|
33
47
|
end
|
34
48
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Status
|
4
|
+
attr_reader :name, :message
|
5
|
+
@status = {}
|
6
|
+
|
7
|
+
def self.ok
|
8
|
+
fetch(:ok, 'status.alive') { |callback| }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.error(message)
|
12
|
+
fetch(:error, message) do |callback|
|
13
|
+
callback.call(message)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def when_error(&callback)
|
18
|
+
@status_callback.call(callback)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def initialize(name, message, &status_callback)
|
23
|
+
@name = name
|
24
|
+
@message = message
|
25
|
+
@status_callback = status_callback
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.fetch(status, message, &callback)
|
29
|
+
@status["#{status}#{message}"] ||= new(status, message, &callback)
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-monitoring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Narciso Benigno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,6 +89,7 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- lib/resque/monitoring/scheduler/last_execution.rb
|
91
91
|
- lib/resque/monitoring/scheduler.rb
|
92
|
+
- lib/resque/monitoring/status.rb
|
92
93
|
- lib/resque/monitoring/version.rb
|
93
94
|
- lib/resque/monitoring.rb
|
94
95
|
homepage: ''
|