tasque 0.0.4 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tasque.rb +1 -0
- data/lib/tasque/configuration.rb +2 -0
- data/lib/tasque/processor.rb +7 -3
- data/lib/tasque/task.rb +6 -4
- data/lib/tasque/task_cancel.rb +10 -0
- data/lib/tasque/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29ec554927e3ba7e306961b983eba1d5d1e1e3734a473206babb678d94340a11
|
4
|
+
data.tar.gz: f063d33729ce3f9e785e4cd1c4b84027a0512721beda6de4b53b2689b740506b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89eb31d3b9d99263bd30d75235856982f9e894df6ad242a448112563918c76e304f8266a83211ae7e2449b1f4846dd69a872a94daab855b217eda2c14f87d73c
|
7
|
+
data.tar.gz: d6d99b0f65889aa0d7fd9661e07e707711a4c2fce1e4bef6f541419e86404c6745fbd008073e4b2e7a8f17911f14e32e79271116746383c963b0ca771f67c5c1
|
data/lib/tasque.rb
CHANGED
data/lib/tasque/configuration.rb
CHANGED
@@ -41,6 +41,7 @@ module Tasque
|
|
41
41
|
attr_accessor :worker
|
42
42
|
attr_accessor :heartbeat
|
43
43
|
attr_accessor :heartbeat_interval
|
44
|
+
attr_accessor :heartbeat_payload
|
44
45
|
attr_accessor :notify
|
45
46
|
|
46
47
|
def initialize
|
@@ -51,6 +52,7 @@ module Tasque
|
|
51
52
|
self.progress_interval = 5 # seconds
|
52
53
|
self.heartbeat = false
|
53
54
|
self.heartbeat_interval = 10 # seconds
|
55
|
+
self.heartbeat_payload = {}
|
54
56
|
self.notify = false
|
55
57
|
end
|
56
58
|
|
data/lib/tasque/processor.rb
CHANGED
@@ -17,17 +17,21 @@ module Tasque
|
|
17
17
|
task.process
|
18
18
|
begin
|
19
19
|
task.result = block.call task
|
20
|
+
task.complete
|
21
|
+
rescue Tasque::TaskCancel => e
|
22
|
+
task.cancel
|
20
23
|
rescue Tasque::TaskError => e
|
21
24
|
task.error = {
|
22
25
|
task_error: e.task_error
|
23
26
|
}
|
27
|
+
task.failure
|
24
28
|
rescue Exception => e
|
25
29
|
task.error = {
|
26
30
|
exception: e.message,
|
27
31
|
backtrace: e.backtrace
|
28
32
|
}
|
33
|
+
task.failure
|
29
34
|
end
|
30
|
-
task.error? ? task.failure : task.complete
|
31
35
|
@current_task = nil
|
32
36
|
end
|
33
37
|
@timers.every(check_interval) do
|
@@ -60,8 +64,8 @@ module Tasque
|
|
60
64
|
heartbeat_timers.every(Tasque.config.heartbeat_interval) do
|
61
65
|
message = {
|
62
66
|
worker: Tasque.config.worker,
|
63
|
-
busy: !@
|
64
|
-
}
|
67
|
+
busy: !@current_task.nil?
|
68
|
+
}.merge(Tasque.config.heartbeat_payload)
|
65
69
|
Insque.broadcast :heartbeat, message
|
66
70
|
end
|
67
71
|
loop do
|
data/lib/tasque/task.rb
CHANGED
@@ -11,7 +11,7 @@ module Tasque
|
|
11
11
|
serialize :params, JSON
|
12
12
|
serialize :result, JSON
|
13
13
|
|
14
|
-
scope :with_task, ->(task) { where(task: task).order priority: :desc }
|
14
|
+
scope :with_task, ->(task) { where(task: task).order priority: :desc, created_at: :asc }
|
15
15
|
scope :minimum_priority, ->(priority) { priority.nil? ? nil : where('priority >= ?', priority) }
|
16
16
|
scope :to_process, -> { where status: %w(new reprocessed) }
|
17
17
|
scope :with_error, -> { where status: 'error' }
|
@@ -98,7 +98,7 @@ module Tasque
|
|
98
98
|
end
|
99
99
|
|
100
100
|
event :cancel do
|
101
|
-
transition any
|
101
|
+
transition any => :canceled
|
102
102
|
end
|
103
103
|
|
104
104
|
|
@@ -112,13 +112,15 @@ module Tasque
|
|
112
112
|
@last_progress_val = val
|
113
113
|
notify
|
114
114
|
end
|
115
|
-
|
115
|
+
end
|
116
|
+
|
117
|
+
state :processing, :cancel do
|
116
118
|
def error!(task_error)
|
117
119
|
raise Tasque::TaskError.new(self, task_error)
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
121
|
-
state :processing, :error do
|
123
|
+
state :processing, :error, :cancel do
|
122
124
|
attr_accessor :error
|
123
125
|
|
124
126
|
def error?
|
data/lib/tasque/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tasque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuri Gomozov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/tasque/configuration.rb
|
145
145
|
- lib/tasque/processor.rb
|
146
146
|
- lib/tasque/task.rb
|
147
|
+
- lib/tasque/task_cancel.rb
|
147
148
|
- lib/tasque/task_error.rb
|
148
149
|
- lib/tasque/version.rb
|
149
150
|
- spec/spec_helper.rb
|
@@ -167,8 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '0'
|
169
170
|
requirements: []
|
170
|
-
|
171
|
-
rubygems_version: 2.7.7
|
171
|
+
rubygems_version: 3.1.2
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: ActiveRecord based task queue
|