sidekiq-cronitor 1.0.0.alpha → 1.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/sidekiq/cronitor.rb +37 -9
- data/lib/sidekiq/cronitor/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7a312993ccafb8425bb94bfff6deec07241ff5e
|
4
|
+
data.tar.gz: 96bba8e59b67eafaf8dda5e42a2b5c4804e41344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65f500c417e836ee253b45c156dcf4fe39ab6e9103d892378e7a0bce8c74f5d1811d0b9359d3a1d953dc8ee32204ae0902a93c2f101c671f690d34e678379253
|
7
|
+
data.tar.gz: 59b58af7800b9a659b0b59f57c3972b50cfcd64459c2975c75728aa745b405a69fbf6f5fe92f1b02041752b1eaf6cc3010b0a5ec8b1f7d6880139404c4aa8b89
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/sidekiq/cronitor.rb
CHANGED
@@ -48,18 +48,21 @@ module Sidekiq::Cronitor
|
|
48
48
|
# Default monitor name to sidekiq worker (class) name
|
49
49
|
kwargs[:opts][:name] ||= name
|
50
50
|
|
51
|
-
# If we're using Sidekiq::Cron and there's a job for this class then use
|
52
|
-
# it's cron schedule for a default not_on_schedudle rule, and tag this as
|
53
|
-
# a cron job
|
54
|
-
if defined?(Sidekiq::Cron) && job = Sidekiq::Cron::Job.all.find { |j| j.klass == name }
|
55
|
-
kwargs[:opts][:rules] ||= [{rule_type: "not_on_schedule", value: job.cron}]
|
56
|
-
kwargs[:opts][:tags] ||= ["cron-job", "sidekiq-cron", "sidekiq-cronitor"]
|
57
|
-
end
|
58
|
-
|
59
51
|
# Some hints about where this monitor came from
|
60
|
-
kwargs[:opts][:tags] ||= [
|
52
|
+
kwargs[:opts][:tags] ||= []
|
53
|
+
kwargs[:opts][:tags] << "sidekiq-cronitor"
|
54
|
+
if environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || Sidekiq.options[:environment]
|
55
|
+
kwargs[:opts][:tags] << environment
|
56
|
+
end
|
61
57
|
kwargs[:opts][:note] ||= "Created by sidekiq-cronitor"
|
62
58
|
|
59
|
+
# If we can find a schedule for this worker then we can automatically add
|
60
|
+
# a not_on_schedule rule and tag it as a cron-job
|
61
|
+
if schedule = cronitor_schedule
|
62
|
+
kwargs[:opts][:rules] ||= [{rule_type: "not_on_schedule", value: schedule}]
|
63
|
+
kwargs[:opts][:tags] << "cron-job"
|
64
|
+
end
|
65
|
+
|
63
66
|
begin
|
64
67
|
@cronitor = Cronitor.new(**kwargs)
|
65
68
|
rescue Cronitor::Error => e
|
@@ -68,6 +71,31 @@ module Sidekiq::Cronitor
|
|
68
71
|
@cronitor = nil
|
69
72
|
end
|
70
73
|
end
|
74
|
+
|
75
|
+
private def cronitor_schedule
|
76
|
+
name = self.name
|
77
|
+
|
78
|
+
if defined?(Sidekiq::Cron)
|
79
|
+
# If we can find a Sidekiq::Cron job with a matching worker class
|
80
|
+
# then presume its schedule.
|
81
|
+
Sidekiq::Cron::Job.all.each do |job|
|
82
|
+
if job.klass == name
|
83
|
+
return job.cron
|
84
|
+
end
|
85
|
+
end
|
86
|
+
elsif defined?(Sidekiq::Periodic)
|
87
|
+
# If we can find a Sidekiq Enterprise Periodic Loop with a matching
|
88
|
+
# worker class then presume its schedule.
|
89
|
+
Sidekiq::Periodic::LoopSet.new.each do |loop_|
|
90
|
+
if loop_.klass == name
|
91
|
+
return loop_.schedule
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# ¯\_(ツ)_/¯
|
97
|
+
return nil
|
98
|
+
end
|
71
99
|
end
|
72
100
|
|
73
101
|
class Middleware
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-cronitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Cochran
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
28
28
|
P4lSfmXxsd1C71ckIp0cyXkPhyTtpyS/5hq9HhuUNzEHkSDe36/Rd1xYKV5JxMC2
|
29
29
|
YAttWFUs06lor2q1wwncPaMtUtbWwW35+1IV6xhs2rFY6DD/I6ZkK3GnHdY=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2017-12-
|
31
|
+
date: 2017-12-10 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: sidekiq
|
metadata.gz.sig
CHANGED
Binary file
|