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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 770e7ef2d608f90f74cb2c7a6bb5fa07d668069b9b056881021a9361630b9683
4
- data.tar.gz: 1d0c6672ffc4c19081dec0ca63e6c1b2b6ca2090007c1608391516592f51002a
3
+ metadata.gz: b70e30c7ee126d2f6198b70ee8357a32d09f26689732921bc68a4a83eb7aec8f
4
+ data.tar.gz: 31cfcf34f77c7bce166f22d9b49e34baa604dbe168ec22c7e577f045f5da8e8e
5
5
  SHA512:
6
- metadata.gz: 22813e39498f31c39bead85e93f89efcdd7eadbd50b2a87e97921cbc5fb7a6d25b688e379d642c26ed15ecc8d86fcb5b90b0e27b230c778bbfc8118fcfdaad50
7
- data.tar.gz: 44ba384c338529141639c61dcbc4c7960bbf1ca139e61f01a2ca5361742aef764edf2f9dc3574579a5d14a428c60ce8699658f2f9773ec2b49258515235b7622
6
+ metadata.gz: 3cd5328d0d63119f7f5877cc886162962c8a6e087e72749c0d2ed4b5f8fc6998a7a0706755126feb0cb84bf9a3fb6e2f549d0942e25edc27ef42f5a32386cd38
7
+ data.tar.gz: 2e564a2607dadfde24e6b532251a41505cf30484b0a89ba94cba482a9deeb067f53b82c92b830ae4819aa407c81aeb009a056048b6bf47490f04189001879a4c
@@ -3,6 +3,7 @@ require "active_record"
3
3
  require "tasque/configuration"
4
4
  require "tasque/task"
5
5
  require "tasque/task_error"
6
+ require "tasque/task_cancel"
6
7
  require "tasque/processor"
7
8
  require "tasque/version"
8
9
 
@@ -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.error = {
24
+ task.result = {
22
25
  task_error: e.task_error
23
26
  }
27
+ task.failure
24
28
  rescue Exception => e
25
- task.error = {
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: !@current_job.nil?
67
+ busy: !@current_task.nil?
64
68
  }.merge(Tasque.config.heartbeat_payload)
65
69
  Insque.broadcast :heartbeat, message
66
70
  end
@@ -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 - [:processing] => :canceled
101
+ transition any => :canceled
102
102
  end
103
103
 
104
104
 
@@ -0,0 +1,10 @@
1
+ module Tasque
2
+ class TaskCancel < Exception
3
+ attr_reader :task
4
+
5
+ def initialize(task)
6
+ @task = task
7
+ end
8
+ end
9
+ end
10
+
@@ -1,3 +1,3 @@
1
1
  module Tasque
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
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.5
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: 2019-07-24 00:00:00.000000000 Z
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
- rubyforge_project:
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