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 +4 -4
- data/README.md +2 -1
- data/lib/crono_trigger/schedulable.rb +16 -14
- data/lib/crono_trigger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3d3157a417d9c99b0da61ea75d9c9efc0af12a1f1f15cc3af121b4b3d673757
|
4
|
+
data.tar.gz: 52c3683c6e3116cfa34b41e83a6b830f63b0f65e4cf49377cc87548b4dc4c5f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
-
|
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)
|
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.
|
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-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chrono
|