perfectqueue 0.8.19 → 0.8.20

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.
data/ChangeLog CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ == 2012-09-08 version 0.8.20
3
+
4
+ * Show log messages when a worker decides next status of a task (finished!,
5
+ release!, release! and cancel_request!)
6
+
7
+
2
8
  == 2012-09-04 version 0.8.19
3
9
 
4
10
  * rdb_compat backend uses >= 0 condition instead of IS NOT NULL to work with
@@ -123,7 +123,7 @@ module PerfectQueue
123
123
  end
124
124
 
125
125
  def process(task)
126
- @log.info "acquired task id=#{@processor_id}: #{task.inspect}"
126
+ @log.info "acquired task task=#{task.key} id=#{@processor_id}: #{task.inspect}"
127
127
  begin
128
128
  r = @runner.new(task)
129
129
  @tm.set_task(task, r)
@@ -132,8 +132,9 @@ module PerfectQueue
132
132
  ensure
133
133
  @tm.task_finished(task)
134
134
  end
135
+ @log.info "completed processing task=#{task.key} id=#{@processor_id}:"
135
136
  rescue
136
- @log.error "process failed id=#{@processor_id}: #{$!.class}: #{$!}"
137
+ @log.error "unexpectedly failed task=#{task.key} id=#{@processor_id}: #{$!.class}: #{$!}"
137
138
  $!.backtrace.each {|bt| @log.warn "\t#{bt}" }
138
139
  raise # force exit
139
140
  end
@@ -54,6 +54,7 @@ module PerfectQueue
54
54
 
55
55
  def set_task(task, runner)
56
56
  task.extend(TaskMonitorHook)
57
+ task.log = @log
57
58
  task.task_monitor = self
58
59
  task.runner = runner
59
60
  @mutex.synchronize {
@@ -97,7 +98,7 @@ module PerfectQueue
97
98
  # callback
98
99
  def task_finished(task, &block)
99
100
  @mutex.synchronize {
100
- ret = block.call if block
101
+ ret = block.call if block # TODO is this ought to be synchronized?
101
102
  if task == @task
102
103
  @task = nil
103
104
  end
@@ -152,6 +153,7 @@ module PerfectQueue
152
153
  end
153
154
 
154
155
  module TaskMonitorHook
156
+ attr_accessor :log
155
157
  attr_accessor :task_monitor
156
158
  attr_accessor :runner
157
159
 
@@ -164,24 +166,28 @@ module PerfectQueue
164
166
  attr_reader :heartbeat_message
165
167
 
166
168
  def finish!(*args, &block)
169
+ @log.info "finished task=#{self.key}" if @log
167
170
  @task_monitor.task_finished(self) {
168
171
  super(*args, &block)
169
172
  }
170
173
  end
171
174
 
172
175
  def release!(*args, &block)
176
+ @log.info "release task=#{self.key}" if @log
173
177
  @task_monitor.task_finished(self) {
174
178
  super(*args, &block)
175
179
  }
176
180
  end
177
181
 
178
182
  def retry!(*args, &block)
183
+ @log.info "retry task=#{self.key}" if @log
179
184
  @task_monitor.task_finished(self) {
180
185
  super(*args, &block)
181
186
  }
182
187
  end
183
188
 
184
189
  def cancel_request!(*args, &block)
190
+ @log.info "cancel request task=#{self.key}" if @log
185
191
  @task_monitor.task_finished(self) {
186
192
  super(*args, &block)
187
193
  }
@@ -1,3 +1,3 @@
1
1
  module PerfectQueue
2
- VERSION = "0.8.19"
2
+ VERSION = "0.8.20"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perfectqueue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.19
4
+ version: 0.8.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-05 00:00:00.000000000 Z
12
+ date: 2012-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel