sidekiq-heartbeat_monitor 1.0.0.2 → 1.0.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: 4f7be0ca733e03a1e84ed4ccafcb1d0ae8f52c92
4
- data.tar.gz: 423742575684aae9713f7bb23e283556f43b3521
3
+ metadata.gz: f506a3446df89fe6dbb973020355ecd670b04532
4
+ data.tar.gz: 9efa759217ce9ccaf1a56b97110f8508542c4645
5
5
  SHA512:
6
- metadata.gz: ec44720762f6c07e9a75432a68ab84c0656a18e86d30bc02cf685af2bb4afad1000ca1f77aecc0af8f65c917535b52d1480c8fc6174510dceb6515b85c5a7462
7
- data.tar.gz: 638342ad54f5a29e785fdd4551cd0877767da18a694180faf717ea2d80b1224f2e328b6f465dde1a1932aae639fa495bab80ac34506f085517b4397efb4194ac
6
+ metadata.gz: 5eb0f1443d34e99930f328cb004a9f1165bf18af47e6df24ba3a3d1752871ad34d0826f9f88f362d138f2d1a230c965312a8a42a0e93b267ca3e2f414f4cc060
7
+ data.tar.gz: b0858151518b1095a8a3484adebf867cb5876008ea3e286417b1ab344d7dd562724b7f8dd353722861c2338cff6af2bfc3195a205d29852796ee40a81fbc0bb5
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Sidekiq Heartbeat Montior Gem
1
+ # Sidekiq Montior Gem
2
2
 
3
3
  This gem adds 2 things:
4
4
  1. A lightweight heartbeat task that runs every few minutes and alerts if it takes longer than a few seconds to start.
@@ -61,15 +61,6 @@ Sidekiq::HeartbeatMonitor.configure(
61
61
 
62
62
  **Note:** `on_backed_up` and `on_slowed_down` accept an array and will always add to existing callbacks (you can combine `slack_notiifer_url` with them)
63
63
 
64
- ### STEP 3. Schedule recurring task
65
- If you're using sidekiq-cron, add this to your `config/scheduler.yml` file:
66
- ```yml
67
- sidekiq_heartbeat_monitor:
68
- cron: "*/15 * * * * *" # Heart beat runs every 15 seconds in this case
69
- class: "Sidekiq::HeartbeatMonitor::Scheduler"
70
- queue: scheduler
71
- ```
72
-
73
64
  ## Testing Your Config
74
65
  To test your config:
75
66
  1. Open your rails console.
@@ -18,6 +18,10 @@ module Sidekiq
18
18
  @on_backed_up = @on_backed_up.to_a + slack_notifier_callback
19
19
  @on_slowed_down = @on_slowed_down.to_a + slack_notifier_callback
20
20
  end
21
+
22
+ unless Sidekiq::Cron::Job.find("sidekiq_monitor").present?
23
+ Sidekiq::Cron::Job.create(name: 'sidekiq_monitor', cron: '*/15 * * * * *', class: 'Sidekiq::HeartbeatMonitor::Scheduler')
24
+ end
21
25
  end
22
26
 
23
27
  def send_test!
@@ -10,7 +10,7 @@ module Sidekiq
10
10
  Sidekiq::Queue.all.each do |q|
11
11
  check_queue_size(q, Sidekiq::HeartbeatMonitor::Config.max_queue_size)
12
12
 
13
- Sidekiq::HeartbeatMonitor::Worker.perform_async(q.name, 15)
13
+ Sidekiq::HeartbeatMonitor::Worker.client_push('class' => self, 'args' => [q.name, 15], 'queue' => q.name)
14
14
  end
15
15
  end
16
16
 
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module HeartbeatMonitor
3
- VERSION = '1.0.0.2'
3
+ VERSION = '1.0.1.0'
4
4
  end
5
5
  end
@@ -10,7 +10,7 @@ module Sidekiq
10
10
  # @param queue_name [String] Name of the queue that this heartbeat is running on.
11
11
  def perform(queue_name, secs_between_beats = 15)
12
12
  current_run_at = Time.now.utc.to_i
13
- last_run_at = $redis.get("Sidekiq/HeartbeatMonitor/Worker/#{queue_name}.last_run_at").to_i
13
+ last_run_at = redis.get("Sidekiq/HeartbeatMonitor/Worker/#{queue_name}.last_run_at").to_i
14
14
 
15
15
  if last_run_at > 0
16
16
  time_since_last_run = current_run_at - last_run_at
@@ -21,7 +21,7 @@ module Sidekiq
21
21
  end
22
22
  end
23
23
 
24
- $redis.set("Sidekiq/HeartbeatMonitor/Worker/#{queue_name}.last_run_at", current_run_at, ex: 1.hour)
24
+ redis.set("Sidekiq/HeartbeatMonitor/Worker/#{queue_name}.last_run_at", current_run_at, ex: 1.hour)
25
25
  end
26
26
 
27
27
  ##
@@ -35,6 +35,11 @@ module Sidekiq
35
35
  true
36
36
  end
37
37
 
38
+ private
39
+
40
+ def redis
41
+ @@redis = defined?($redis) ? $redis : Redis.new
42
+ end
38
43
 
39
44
  end
40
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-heartbeat_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.2
4
+ version: 1.0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay El-Kaake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-15 00:00:00.000000000 Z
11
+ date: 2019-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dont_repeat_for