queue_dispatcher 2.1.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/lib/queue_dispatcher.rb +1 -0
- data/lib/queue_dispatcher/acts_as_task.rb +12 -2
- data/lib/queue_dispatcher/acts_as_task_queue.rb +6 -6
- data/lib/queue_dispatcher/message_sending.rb +5 -2
- data/lib/queue_dispatcher/target_container.rb +9 -0
- data/lib/queue_dispatcher/version.rb +1 -1
- metadata +19 -18
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
OGE1Y2QwOTBmNWNkNjYwZGU2ZTZjNWYxZTNmZDJiMmE2YjJkYmNmZmQxMDJk
|
10
|
-
ODEwM2UwNzIwYzAxMjBiM2VlZTFkOWZjYjY3N2RlZWExM2U1YmFiZjYyMGU4
|
11
|
-
YWRhZDFhNjNiZWYyMTFmZWViYTJjN2NlY2Y5ZGY4ODFhY2NkNDI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OGRlMDlhMWE1YzZjYTBkMGI2OWIyMWM3NTliMGE4MDE3NTk3ZGY4YmEzMjBi
|
14
|
-
NmUyZGI0ZjNjNGI5MmJjYzRhOGQ2NmE3ODIzODRjNjJlYzEwOTUxODAxNTc3
|
15
|
-
YmFjZmRlMDY3MDE3N2FhZTFkMTk5NDYxY2YxOTM0YWFjYzVlODE=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f35bcc5afab97bb7da1c28e6c33db73216e8b29e
|
4
|
+
data.tar.gz: cb909b73223caf2192d7f4a437cb2f49be17a97e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 970e6acfbb9a957ad130615294e5783c60ff2735ca3f96c756a683f8f807a1ac478351df68b8f997459e5251b43afcf5d6d6268e0b454071f0ee47a5e32041df
|
7
|
+
data.tar.gz: 1eeec8fc00fa057ab6fb35856f04e0c578c0798a96832e40fcba76dd71ca65e5f08a4579e233e16fbb0a9778316874d0c262d51444ec05360780bf9f00b63c95
|
data/lib/queue_dispatcher.rb
CHANGED
@@ -5,6 +5,7 @@ require 'queue_dispatcher/acts_as_task_queue'
|
|
5
5
|
require 'queue_dispatcher/acts_as_task_controller'
|
6
6
|
require 'queue_dispatcher/deserialization_error'
|
7
7
|
require 'queue_dispatcher/message_sending'
|
8
|
+
require 'queue_dispatcher/target_container'
|
8
9
|
require 'queue_dispatcher/qd_logger'
|
9
10
|
require 'queue_dispatcher/rc_and_msg'
|
10
11
|
require 'queue_dispatcher/yaml_ext'
|
@@ -56,6 +56,15 @@ module QueueDispatcher
|
|
56
56
|
end
|
57
57
|
|
58
58
|
|
59
|
+
def payload
|
60
|
+
if target.is_a?(QueueDispatcher::TargetContainer)
|
61
|
+
target.payload
|
62
|
+
else
|
63
|
+
target
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
59
68
|
# Add task_id to the args
|
60
69
|
def args
|
61
70
|
a = super
|
@@ -68,7 +77,7 @@ module QueueDispatcher
|
|
68
77
|
def update_state(result, remove_from_queue = false)
|
69
78
|
rc = output = error_msg = nil
|
70
79
|
|
71
|
-
if result.methods.include?(:rc) && result.methods.include?(:output) && result.methods.include?(:error_msg)
|
80
|
+
if result.methods.map(&:to_sym).include?(:rc) && result.methods.map(&:to_sym).include?(:output) && result.methods.map(&:to_sym).include?(:error_msg)
|
72
81
|
rc = result.rc
|
73
82
|
output = result.output
|
74
83
|
error_msg = result.error_msg
|
@@ -203,7 +212,8 @@ module QueueDispatcher
|
|
203
212
|
|
204
213
|
# Execute task
|
205
214
|
def execute!
|
206
|
-
|
215
|
+
payload.task_id = id if payload.methods.include?(:task_id=)
|
216
|
+
payload.send(method_name, *args)
|
207
217
|
end
|
208
218
|
|
209
219
|
end
|
@@ -303,11 +303,11 @@ module QueueDispatcher
|
|
303
303
|
# Start
|
304
304
|
task.update_attributes :state => 'acquire_lock', :perc_finished => 0
|
305
305
|
get_lock_for task
|
306
|
-
log :msg => "#{name}: Starting task #{task.id} (#{task.
|
306
|
+
log :msg => "#{name}: Starting task #{task.id} (#{task.payload.class.name}.#{task.method_name})...", :print_log => print_log
|
307
307
|
task.update_attributes :state => 'running'
|
308
308
|
|
309
309
|
# Execute the method defined in task.method
|
310
|
-
if task.
|
310
|
+
if task.payload.methods.map(&:to_sym).include?(task.method_name.to_sym)
|
311
311
|
if task.dependent_tasks_had_errors
|
312
312
|
error_msg = 'Dependent tasks had errors!'
|
313
313
|
log :msg => error_msg,
|
@@ -315,12 +315,12 @@ module QueueDispatcher
|
|
315
315
|
:print_log => print_log
|
316
316
|
result = QueueDispatcher::RcAndMsg.bad_rc error_msg
|
317
317
|
else
|
318
|
-
|
319
|
-
|
318
|
+
payload = task.payload
|
319
|
+
payload.logger = @logger if payload.methods.include?(:logger=) || payload.methods.include?('logger=')
|
320
320
|
result = task.execute!
|
321
321
|
end
|
322
322
|
else
|
323
|
-
error_msg = "unknown method '#{task.method_name}' for #{task.
|
323
|
+
error_msg = "unknown method '#{task.method_name}' for #{task.payload.class.name}!"
|
324
324
|
log :msg => error_msg,
|
325
325
|
:sev => :warn,
|
326
326
|
:print_log => print_log
|
@@ -331,7 +331,7 @@ module QueueDispatcher
|
|
331
331
|
task.update_state result
|
332
332
|
cleanup_locks_after_error_for task
|
333
333
|
task.update_attribute :task_queue_id, nil unless acts_as_task_queue_config.leave_finished_tasks_in_queue
|
334
|
-
log :msg => "#{name}: Task #{task.id} (#{task.
|
334
|
+
log :msg => "#{name}: Task #{task.id} (#{task.payload.class.name}.#{task.method_name}) finished with state '#{task.state}'.", :print_log => print_log
|
335
335
|
|
336
336
|
# Wait between tasks
|
337
337
|
sleep acts_as_task_queue_config.task_finish_wait_time
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module QueueDispatcher
|
2
2
|
class QueueDispatcherProxy < ActiveSupport::ProxyObject
|
3
3
|
def initialize(target, options = {})
|
4
|
-
|
4
|
+
## Workaround for Rails 4.2: All serialized objects which respond to :id will get typecasted by its id. This
|
5
|
+
## behaviour doesn't allow to store ActiveRecord objects. We handle this, by encapsulating all objects in
|
6
|
+
## before storing.
|
7
|
+
@target = TargetContainer.new(target)
|
5
8
|
@options = options
|
6
9
|
end
|
7
10
|
|
@@ -10,7 +13,7 @@ module QueueDispatcher
|
|
10
13
|
terminate_immediately = @options.delete(:terminate_immediately)
|
11
14
|
terminate_immediately = terminate_immediately.nil? ? false : terminate_immediately
|
12
15
|
terminate_immediately = @options[:queue].nil? ? true : terminate_immediately
|
13
|
-
task_queue_name = @options.delete(:queue) || "#{@target.to_s}_#{::Time.now.to_f}"
|
16
|
+
task_queue_name = @options.delete(:queue) || "#{@target.payload.to_s}_#{::Time.now.to_f}"
|
14
17
|
task_queue = ::TaskQueue.find_or_create_by_name task_queue_name, terminate_immediately: terminate_immediately
|
15
18
|
|
16
19
|
# Create Task
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue_dispatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Kurmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sys-proctable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.9.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.9.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: deadlock_retry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: spawnling
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: haml
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: will_paginate
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: jquery-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: Queue_Dispatcher executes asynchronous tasks in the background.
|
@@ -101,7 +101,7 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- .gitignore
|
104
|
+
- ".gitignore"
|
105
105
|
- Gemfile
|
106
106
|
- LICENSE
|
107
107
|
- README.rdoc
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- lib/queue_dispatcher/rc_and_msg.rb
|
146
146
|
- lib/queue_dispatcher/serialization/active_record.rb
|
147
147
|
- lib/queue_dispatcher/syck_ext.rb
|
148
|
+
- lib/queue_dispatcher/target_container.rb
|
148
149
|
- lib/queue_dispatcher/version.rb
|
149
150
|
- lib/queue_dispatcher/yaml_ext.rb
|
150
151
|
- lib/tasks/queue_dispatcher.rake
|
@@ -159,17 +160,17 @@ require_paths:
|
|
159
160
|
- lib
|
160
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
161
162
|
requirements:
|
162
|
-
- -
|
163
|
+
- - ">="
|
163
164
|
- !ruby/object:Gem::Version
|
164
165
|
version: '0'
|
165
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
167
|
requirements:
|
167
|
-
- -
|
168
|
+
- - ">="
|
168
169
|
- !ruby/object:Gem::Version
|
169
170
|
version: '0'
|
170
171
|
requirements: []
|
171
172
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.2.2
|
173
174
|
signing_key:
|
174
175
|
specification_version: 4
|
175
176
|
summary: This Gem installs a queue dispatcher for handling asynchronous tasks
|