tasque 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tasque.rb +1 -0
- data/lib/tasque/processor.rb +8 -4
- data/lib/tasque/task.rb +2 -2
- 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: b70e30c7ee126d2f6198b70ee8357a32d09f26689732921bc68a4a83eb7aec8f
|
4
|
+
data.tar.gz: 31cfcf34f77c7bce166f22d9b49e34baa604dbe168ec22c7e577f045f5da8e8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cd5328d0d63119f7f5877cc886162962c8a6e087e72749c0d2ed4b5f8fc6998a7a0706755126feb0cb84bf9a3fb6e2f549d0942e25edc27ef42f5a32386cd38
|
7
|
+
data.tar.gz: 2e564a2607dadfde24e6b532251a41505cf30484b0a89ba94cba482a9deeb067f53b82c92b830ae4819aa407c81aeb009a056048b6bf47490f04189001879a4c
|
data/lib/tasque.rb
CHANGED
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
|
-
task.
|
24
|
+
task.result = {
|
22
25
|
task_error: e.task_error
|
23
26
|
}
|
27
|
+
task.failure
|
24
28
|
rescue Exception => e
|
25
|
-
task.
|
29
|
+
task.result = {
|
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,7 +64,7 @@ module Tasque
|
|
60
64
|
heartbeat_timers.every(Tasque.config.heartbeat_interval) do
|
61
65
|
message = {
|
62
66
|
worker: Tasque.config.worker,
|
63
|
-
busy: !@
|
67
|
+
busy: !@current_task.nil?
|
64
68
|
}.merge(Tasque.config.heartbeat_payload)
|
65
69
|
Insque.broadcast :heartbeat, message
|
66
70
|
end
|
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
|
|
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.1.0
|
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-10-01 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.8
|
171
|
+
rubygems_version: 3.1.2
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: ActiveRecord based task queue
|