sqsrun 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ == 2011-07-19 version 0.6.0
3
+
4
+ * Changed not to set visibility_timeout=0 when a task is failed
5
+ * Added -E, --release-on-fail option
6
+
7
+
2
8
  == 2011-07-18 version 0.5.0
3
9
 
4
10
  * Added respectable timeout implementation
@@ -15,6 +15,7 @@ defaults = {
15
15
  :timeout => 30,
16
16
  :interval => 1,
17
17
  :kill_retry => 60,
18
+ :release_on_fail => false,
18
19
  }
19
20
 
20
21
  conf = { }
@@ -77,7 +78,7 @@ op.on('-e', '--extend-timeout SEC', 'Threashold time before extending visibility
77
78
  conf[:extend_timeout] = i
78
79
  }
79
80
 
80
- op.on('-x', '--kill-timeout SEC', 'Threashold time before killing process (default: timeout * 5)', Integer) {|i|
81
+ op.on('-x', '--kill-timeout SEC', 'Threashold time before killing process (default: timeout * 10)', Integer) {|i|
81
82
  conf[:kill_timeout] = i
82
83
  }
83
84
 
@@ -89,6 +90,10 @@ op.on('-i', '--interval SEC', 'Polling interval (default: 1)', Integer) {|i|
89
90
  conf[:interval] = i
90
91
  }
91
92
 
93
+ op.on('-E', '--release-on-fail', 'Releases lock if task failed so that other node can retry immediately', TrueClass) {|b|
94
+ conf[:release_on_fail] = b
95
+ }
96
+
92
97
  op.on('-d', '--daemon PIDFILE', 'Daemonize (default: foreground)') {|s|
93
98
  conf[:daemon] = s
94
99
  }
@@ -159,7 +164,7 @@ begin
159
164
  end
160
165
 
161
166
  unless conf[:kill_timeout]
162
- conf[:kill_timeout] = conf[:timeout] * 5
167
+ conf[:kill_timeout] = conf[:timeout] * 10
163
168
  end
164
169
 
165
170
  if !conf[:queue] && (type != :list && type != :conf)
@@ -1,5 +1,5 @@
1
1
  module SQSRun
2
2
 
3
- VERSION = '0.5.0'
3
+ VERSION = '0.6.0'
4
4
 
5
5
  end
data/lib/sqsrun/worker.rb CHANGED
@@ -14,6 +14,7 @@ class Worker
14
14
  @kill_timeout = conf[:kill_timeout]
15
15
  @kill_retry = conf[:kill_retry]
16
16
  @interval = conf[:interval]
17
+ @release_on_fail = conf[:release_on_fail]
17
18
  @finished = false
18
19
 
19
20
  @extender = TimerThread.new(@visibility_timeout, @extend_timeout, @kill_timeout, @kill_retry)
@@ -78,13 +79,13 @@ class Worker
78
79
 
79
80
  def process(msg)
80
81
  puts "started id=#{msg.id}"
81
- thread = Thread.new(msg.to_s, &@run_proc.method(:call))
82
82
 
83
83
  @extender.set_message(msg)
84
84
 
85
85
  success = false
86
86
  begin
87
- thread.join
87
+ @run_proc.call(msg.to_s)
88
+ puts "finished id=#{msg.id}"
88
89
  success = true
89
90
  rescue
90
91
  puts "failed id=#{msg.id}: #{$!}"
@@ -98,7 +99,9 @@ class Worker
98
99
  if success
99
100
  msg.delete
100
101
  else
101
- msg.visibility = 0
102
+ if @release_on_fail
103
+ msg.visibility = 0
104
+ end
102
105
  end
103
106
  end
104
107
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqsrun
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 0.5.0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sadayuki Furuhashi