simple_job 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/lib/simple_job/job_definition.rb +9 -7
- data/lib/simple_job/sqs_job_queue.rb +5 -1
- data/lib/simple_job/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
= Simple Job
|
2
2
|
|
3
|
+
== Version 0.2.0
|
4
|
+
* Added :max_executions option to SQSJobQueue#poll
|
5
|
+
* Bug fix to :replace_existing option of JobDefinition::register_simple_job declaration - wasn't properly leaving old definitions
|
6
|
+
|
3
7
|
== Version 0.1.0
|
4
8
|
* Added AWS CloudWatch monitors for job execution
|
5
9
|
* Added :replace_existing option to register_simple_job
|
@@ -129,23 +129,25 @@ module JobDefinition
|
|
129
129
|
def register_simple_job(options = {})
|
130
130
|
default_type = self.name.split('::').last.underscore.to_sym
|
131
131
|
|
132
|
-
replace_existing = options.delete(:replace_existing)
|
132
|
+
replace_existing = options.delete(:replace_existing)
|
133
|
+
replace_existing = true if replace_existing.nil?
|
133
134
|
|
134
|
-
|
135
|
+
new_definition = {
|
135
136
|
:class => self,
|
136
137
|
:type => default_type,
|
137
138
|
:versions => [ '1' ],
|
138
139
|
}.merge(options)
|
139
140
|
|
140
|
-
|
141
|
-
|
142
|
-
|
141
|
+
new_definition[:type] = new_definition[:type].to_sym
|
142
|
+
new_definition[:versions] = Array(new_definition[:versions])
|
143
|
+
new_definition[:versions].collect! { |value| value.to_s }
|
143
144
|
|
144
145
|
if replace_existing
|
145
|
-
::SimpleJob::JobDefinition.job_definitions.
|
146
|
+
::SimpleJob::JobDefinition.job_definitions.delete(@definition)
|
147
|
+
@definition = new_definition
|
146
148
|
end
|
147
149
|
|
148
|
-
::SimpleJob::JobDefinition.job_definitions <<
|
150
|
+
::SimpleJob::JobDefinition.job_definitions << new_definition
|
149
151
|
end
|
150
152
|
|
151
153
|
def job_queue(queue_type = nil)
|
@@ -93,7 +93,8 @@ class SQSJobQueue < JobQueue
|
|
93
93
|
:attributes => [ :sent_at, :receive_count, :first_received_at ],
|
94
94
|
:raise_exceptions => false,
|
95
95
|
:idle_timeout => nil,
|
96
|
-
:poll_interval => DEFAULT_POLL_INTERVAL
|
96
|
+
:poll_interval => DEFAULT_POLL_INTERVAL,
|
97
|
+
:max_executions => nil
|
97
98
|
}.merge(options)
|
98
99
|
|
99
100
|
message_handler = block || lambda do |definition, message|
|
@@ -114,7 +115,9 @@ class SQSJobQueue < JobQueue
|
|
114
115
|
|
115
116
|
last_message_at = Time.now
|
116
117
|
|
118
|
+
max_executions = options[:max_executions]
|
117
119
|
loop do
|
120
|
+
break if max_executions && (max_executions <= 0)
|
118
121
|
last_message = nil
|
119
122
|
current_start_milliseconds = get_milliseconds
|
120
123
|
current_job_type = 'unknown'
|
@@ -147,6 +150,7 @@ class SQSJobQueue < JobQueue
|
|
147
150
|
logger.error(e.backtrace.join("\n "))
|
148
151
|
end
|
149
152
|
end
|
153
|
+
max_executions -= 1 if max_executions
|
150
154
|
break if exit_next
|
151
155
|
end
|
152
156
|
|
data/lib/simple_job/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Dawson
|