crono_trigger 0.3.4 → 0.4.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
  SHA256:
3
- metadata.gz: 035751ab4333491a769367b5d28fbace76bcb70806400cc10f6338c89b65e394
4
- data.tar.gz: '0917037bd6064a166b2ff0a95d7ffa094e44a7ed54c8b08f120e593df41660bc'
3
+ metadata.gz: e3d3157a417d9c99b0da61ea75d9c9efc0af12a1f1f15cc3af121b4b3d673757
4
+ data.tar.gz: 52c3683c6e3116cfa34b41e83a6b830f63b0f65e4cf49377cc87548b4dc4c5f4
5
5
  SHA512:
6
- metadata.gz: 27bd18f70a271450c1c316d3cdf10b837f1b0322026a72788373633be3743d20719654e40e2dba528f2b2f178deee893930a6a208984709bafcf3e40d9bb7ae7
7
- data.tar.gz: 142f7e3a5fc634c81142bb254dae96e20a20d6efb6fb6a425ca01f7d77af2a89f43073296ce901127c4fef6fab9a4c5b6b679fd8033b0d019c3a79c8e490ad82
6
+ metadata.gz: 63f1eee5323fd5c1fff137c4d4204b06b9aca648d97d82cc3168fecda11d95d65d771a4b063615dbe4e5ac7b5767e888b02b4f3cbbafd09c912a122601060391
7
+ data.tar.gz: b30388357a341e278474d410b5a907e690ac1c97986b4e779fda3a4430d73b76c1aee8ea505cd5852223a63e9983b81b50b2a8a80d97cb9b44825b0071afeb2b
data/README.md CHANGED
@@ -98,8 +98,9 @@ class MailNotification < ActiveRecord::Base
98
98
  execute_lock_timeout: 300,
99
99
  }
100
100
 
101
- # `execute` callback is defined
101
+ # `execute`, `retry` callback is defined
102
102
  # can use `before_execute`, `after_execute`, `around_execute`
103
+ # `before_retry`, `after_retry`, `around_retry`
103
104
 
104
105
  # If execute method raise Exception, worker retry task until reach `retry_limit`
105
106
  # If `retry_count` reaches `retry_limit`, task schedule is reset.
@@ -30,7 +30,7 @@ module CronoTrigger
30
30
  self.crono_trigger_options ||= {}
31
31
  self.executable_conditions ||= []
32
32
 
33
- define_model_callbacks :execute
33
+ define_model_callbacks :execute, :retry
34
34
 
35
35
  scope :executables, ->(from: Time.current, limit: CronoTrigger.config.executor_thread * 3 || 100, including_locked: false) do
36
36
  t = arel_table
@@ -156,21 +156,23 @@ module CronoTrigger
156
156
  end
157
157
 
158
158
  def retry!
159
- logger.info "Retry #{self.class}-#{id}" if logger
160
-
161
- now = Time.current
162
- wait = crono_trigger_options[:exponential_backoff] ? retry_interval * [2 * (retry_count - 1), 1].max : retry_interval
163
- attributes = {
164
- crono_trigger_column_name(:next_execute_at) => now + wait,
165
- crono_trigger_column_name(:execute_lock) => 0,
166
- crono_trigger_column_name(:locked_by) => nil,
167
- }
159
+ run_callbacks :retry do
160
+ logger.info "Retry #{self.class}-#{id}" if logger
161
+
162
+ now = Time.current
163
+ wait = crono_trigger_options[:exponential_backoff] ? retry_interval * [2 * (retry_count - 1), 1].max : retry_interval
164
+ attributes = {
165
+ crono_trigger_column_name(:next_execute_at) => now + wait,
166
+ crono_trigger_column_name(:execute_lock) => 0,
167
+ crono_trigger_column_name(:locked_by) => nil,
168
+ }
169
+
170
+ if self.class.column_names.include?("retry_count")
171
+ attributes.merge!(retry_count: retry_count.to_i + 1)
172
+ end
168
173
 
169
- if self.class.column_names.include?("retry_count")
170
- attributes.merge!(retry_count: retry_count.to_i + 1)
174
+ update_columns(attributes)
171
175
  end
172
-
173
- update_columns(attributes)
174
176
  end
175
177
 
176
178
  def reset!(update_last_executed_at = true)
@@ -1,3 +1,3 @@
1
1
  module CronoTrigger
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crono_trigger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chrono