check_and_notify 0.1.3 → 0.1.4

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
- SHA1:
3
- metadata.gz: e8b070e816e8bca6c2c8be935875c2c5030dc5b2
4
- data.tar.gz: cf82a98f70309b75b3e6648567118c07bdd94857
2
+ SHA256:
3
+ metadata.gz: bf6124daf46f2509ec637d3b62db98d10d08063d60fc68c62f77f47aa0b484df
4
+ data.tar.gz: c8e1df0bc22fae0d171bdeaac87306e82b021b5a5275c2b71e9b3052f5de9abd
5
5
  SHA512:
6
- metadata.gz: 7a7f5fb211c66c9596d056c2bfd403ca498c443821ee87ce464274c0f188c39729aa0b52f61e992a8b428556f877d641e8faed0180ad12e7cb7e14caa41aa99f
7
- data.tar.gz: 5b1a5cb24c444a3b39c917f18bec768edb0b7a174a4547ae4514c2f4cdc6a4138eb7205c6da0a05c0817946ce73d23d1c70d3a990c35b79e130c5185f3918009
6
+ metadata.gz: 28dd249217c6d0a2743868d9ba7faaa1eca3d888a513ebd7dddf0ed753280bc9869c3e367ae71b4f52c2a54d36295002d1ae863a42e6664037ff93c11df7ac84
7
+ data.tar.gz: 4be1b3a88dfcafc34e0687d3f76cf2ca40f3c452da601d995c513c50c14b50c3f840a521edfb41190a6dea34f58fd90d89f2b0290a32e5e71daa2bda9ac7649c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.4
2
+
3
+ - initialize CheckAndNotify::Cron.init_every_one_minute_cron
4
+
1
5
  # 0.1.3
2
6
 
3
7
  - Update gem dependency versions
@@ -3,10 +3,12 @@ module CheckAndNotify
3
3
  mattr_accessor :check_after_one_hour_callbacks
4
4
  mattr_accessor :check_after_ten_minutes_callbacks
5
5
  mattr_accessor :check_after_thirty_minutes_callbacks
6
+ mattr_accessor :check_after_one_minute_callbacks
6
7
 
7
8
  self.check_after_one_hour_callbacks = []
8
9
  self.check_after_ten_minutes_callbacks = []
9
10
  self.check_after_thirty_minutes_callbacks = []
11
+ self.check_after_one_minute_callbacks = []
10
12
 
11
13
  def self.check_after_one_hour(&block)
12
14
  self.check_after_one_hour_callbacks << block
@@ -19,5 +21,9 @@ module CheckAndNotify
19
21
  def self.check_after_ten_minutes(&block)
20
22
  self.check_after_ten_minutes_callbacks << block
21
23
  end
24
+
25
+ def self.check_after_one_minute(&block)
26
+ self.check_after_one_minute_callbacks << block
27
+ end
22
28
  end
23
29
  end
@@ -4,6 +4,7 @@ module CheckAndNotify
4
4
  init_every_hour_cron
5
5
  init_every_ten_minutes_cron
6
6
  init_every_thirty_minutes_cron
7
+ init_every_one_minute_cron
7
8
  end
8
9
 
9
10
  private
@@ -31,5 +32,13 @@ module CheckAndNotify
31
32
  class: 'CheckAndNotify::Workers::CheckEveryThirtyMinutesWorker'
32
33
  })
33
34
  end
35
+
36
+ def self.init_every_one_minute_cron
37
+ Sidekiq::Cron::Job.create({
38
+ name: 'CheckEveryOneMinuteWorker',
39
+ cron: '*/1 * * * *',
40
+ class: 'CheckAndNotify::Workers::CheckEveryOneMinuteWorker'
41
+ })
42
+ end
34
43
  end
35
44
  end
@@ -1,3 +1,3 @@
1
1
  module CheckAndNotify
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,19 @@
1
+ module CheckAndNotify
2
+ module Workers
3
+ class CheckEveryOneMinuteWorker
4
+ include Sidekiq::Worker
5
+ sidekiq_options retry: 1
6
+
7
+ def perform
8
+ callbacks_size = CheckAndNotify::Callbacks.
9
+ check_after_one_minute_callbacks.count
10
+
11
+ callbacks_size.times do |index|
12
+ SlackNotifierWorker.perform_async(
13
+ index, SlackNotifierWorker::EVERY_ONE_MINUTE
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -7,6 +7,7 @@ module CheckAndNotify
7
7
  EVERY_HOUR = 3600
8
8
  EVERY_THIRTY_MINUTES = 1800
9
9
  EVERY_TEN_MINUTES = 600
10
+ EVERY_ONE_MINUTE = 60
10
11
 
11
12
  def perform(callback_index, callbacks_array_type)
12
13
  callback = case callbacks_array_type
@@ -19,6 +20,9 @@ module CheckAndNotify
19
20
  when EVERY_TEN_MINUTES
20
21
  CheckAndNotify::Callbacks.
21
22
  check_after_ten_minutes_callbacks[callback_index]
23
+ when EVERY_ONE_MINUTE
24
+ CheckAndNotify::Callbacks.
25
+ check_after_one_minute_callbacks[callback_index]
22
26
  end
23
27
 
24
28
  result = callback.call
@@ -11,6 +11,7 @@ require "check_and_notify/workers/slack_notifier_worker"
11
11
  require "check_and_notify/workers/check_every_hour_worker"
12
12
  require "check_and_notify/workers/check_every_thirty_minutes_worker"
13
13
  require "check_and_notify/workers/check_every_ten_minutes_worker"
14
+ require "check_and_notify/workers/check_every_one_minute_worker"
14
15
 
15
16
  module CheckAndNotify
16
17
  def self.init_cron
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_and_notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Marion dela Cruz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-09 00:00:00.000000000 Z
11
+ date: 2019-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -147,6 +147,7 @@ files:
147
147
  - lib/check_and_notify/notifiers/slack.rb
148
148
  - lib/check_and_notify/version.rb
149
149
  - lib/check_and_notify/workers/check_every_hour_worker.rb
150
+ - lib/check_and_notify/workers/check_every_one_minute_worker.rb
150
151
  - lib/check_and_notify/workers/check_every_ten_minutes_worker.rb
151
152
  - lib/check_and_notify/workers/check_every_thirty_minutes_worker.rb
152
153
  - lib/check_and_notify/workers/slack_notifier_worker.rb
@@ -170,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
171
  version: '0'
171
172
  requirements: []
172
173
  rubyforge_project:
173
- rubygems_version: 2.6.11
174
+ rubygems_version: 2.7.7
174
175
  signing_key:
175
176
  specification_version: 4
176
177
  summary: Calls a callback regularly and notifies when it returns true