iron_worker 3.0.2 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/TODO.txt +2 -0
- data/lib/iron_worker/api_client.rb +10 -0
- data/lib/iron_worker/client.rb +8 -0
- data/lib/iron_worker/version.rb +1 -1
- data/lib/iron_worker/worker_helper.rb +11 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29655dbb8e3be4aca0cf5aad2aedf29dbdbd1273
|
4
|
+
data.tar.gz: 8241a5089cd02b7fccb10d8d4b4e5daca4eaff99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f53ddebc9901b1b7e618670f06a93c5aebf71c99fd29f2d1d670fcc774f940ac17e2f4a664b823c68df1e9fc69a4d8b8158493085aef09725c0abb9c02e1015
|
7
|
+
data.tar.gz: c91b832292b7183cbedd2e1ced67f13d9ac112cf64326f5a134b38d17d9db9a02de632f3b366a5d9f99c11ffe84be2aa38ee1af5a8d705e1290fa6448e2fe121
|
data/README.md
CHANGED
@@ -133,6 +133,17 @@ task = client.tasks.create('MyWorker', {:client => 'Joe'}, {:delay => 180})
|
|
133
133
|
puts task.id
|
134
134
|
```
|
135
135
|
|
136
|
+
### tasks.bulk_create(code_name, array_of_params = [], options = {})
|
137
|
+
|
138
|
+
Queue more than 1 tasks in a single api call for the code package specified by `code_name`, passing an array of params/payloads and returning a tasks object with the ids of each task queued.
|
139
|
+
Visit http://dev.iron.io/worker/reference/api/#queue_a_task for more information about the available options.
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
task_ids = client.tasks.bulk_create('hello_ruby', [{:hello => "world"}, {:hello => "world"}, {:hello => "world"}], {:cluster => "mem1"} )
|
143
|
+
puts tasks_ids
|
144
|
+
# => #<OpenStruct tasks=[{"id"=>"54cc11b8855dc73d9209ce0d"}, {"id"=>"54cc11b8855dc73d9209ce0e"}, {"id"=>"54cc11b8855dc73d9209ce0f"}}], msg="Queued up">
|
145
|
+
```
|
146
|
+
|
136
147
|
### tasks.cancel(task_id)
|
137
148
|
|
138
149
|
Cancel the task specified by `task_id`.
|
@@ -210,8 +221,6 @@ puts schedule.id
|
|
210
221
|
- **priority**: Setting the priority of your job. Valid values are 0, 1, and 2. The default is 0. Higher values means tasks spend less time in the queue once they come off the schedule.
|
211
222
|
- **start_at**: The time the scheduled task should first be run.
|
212
223
|
- **timeout**: The maximum runtime of your task in seconds. No task can exceed 3600 seconds (60 minutes). The default is 3600 but can be set to a shorter duration.
|
213
|
-
- **delay**: The number of seconds to delay before scheduling the tasks. Default is 0.
|
214
|
-
- **task_delay**: The number of seconds to delay before actually queuing the task. Default is 0.
|
215
224
|
- **label**: Optional label for adding custom labels to scheduled tasks.
|
216
225
|
- **cluster**: cluster name ex: "high-mem" or "dedicated". This is a premium feature for customers to have access to more powerful or custom built worker solutions. Dedicated worker clusters exist for users who want to reserve a set number of workers just for their queued tasks. If not set default is set to "default" which is the public IronWorker cluster.
|
217
226
|
|
data/TODO.txt
ADDED
@@ -88,6 +88,16 @@ module IronWorker
|
|
88
88
|
parse_response(post("projects/#{@project_id}/tasks", {:tasks => [{:code_name => code_name, :payload => payload}.merge(options)]}))
|
89
89
|
end
|
90
90
|
|
91
|
+
def tasks_bulk_create(code_name, array_of_payloads, options)
|
92
|
+
array_of_tasks = array_of_payloads.map! do |payload|
|
93
|
+
{
|
94
|
+
:code_name => code_name,
|
95
|
+
:payload => payload.is_a?(String) ? payload : payload.to_json
|
96
|
+
}.merge(options)
|
97
|
+
end
|
98
|
+
parse_response(post("projects/#{@project_id}/tasks", {:tasks => array_of_tasks}))
|
99
|
+
end
|
100
|
+
|
91
101
|
def tasks_cancel(id)
|
92
102
|
check_id(id)
|
93
103
|
parse_response(post("projects/#{@project_id}/tasks/#{id}/cancel"))
|
data/lib/iron_worker/client.rb
CHANGED
@@ -313,6 +313,14 @@ EXEC_FILE
|
|
313
313
|
OpenStruct.new(t)
|
314
314
|
end
|
315
315
|
|
316
|
+
def tasks_bulk_create(code_name, params = [], options = {})
|
317
|
+
IronCore::Logger.debug 'IronWorkerNG', "Calling tasks.bulk_create_legacy with code_name='#{code_name}', params='#{params.to_s}' and options='#{options.to_s}'"
|
318
|
+
|
319
|
+
res = @api.tasks_bulk_create(code_name, params, options)
|
320
|
+
|
321
|
+
OpenStruct.new(res)
|
322
|
+
end
|
323
|
+
|
316
324
|
def tasks_create_legacy(code_name, params = {}, options = {})
|
317
325
|
IronCore::Logger.debug 'IronWorker', "Calling tasks.create_legacy with code_name='#{code_name}', params='#{params.to_s}' and options='#{options.to_s}'"
|
318
326
|
|
data/lib/iron_worker/version.rb
CHANGED
@@ -13,6 +13,7 @@ module IronWorker
|
|
13
13
|
|
14
14
|
def self.load
|
15
15
|
return if @@loaded
|
16
|
+
|
16
17
|
0.upto($*.length - 2) do |i|
|
17
18
|
@@args[:root] = $*[i + 1] if $*[i] == '-d'
|
18
19
|
@@args[:payload_file] = $*[i + 1] if $*[i] == '-payload'
|
@@ -20,6 +21,16 @@ module IronWorker
|
|
20
21
|
@@args[:task_id] = $*[i + 1] if $*[i] == '-id'
|
21
22
|
end
|
22
23
|
|
24
|
+
# New way is ENV vars, so check those too
|
25
|
+
# TASK_ID
|
26
|
+
# PAYLOAD_FILE
|
27
|
+
# TASK_DIR
|
28
|
+
# CONFIG_FILE
|
29
|
+
@@args[:task_id] = ENV['TASK_ID'] if ENV['TASK_ID']
|
30
|
+
@@args[:payload_file] = ENV['PAYLOAD_FILE'] if ENV['PAYLOAD_FILE']
|
31
|
+
@@args[:config_file] = ENV['CONFIG_FILE'] if ENV['CONFIG_FILE']
|
32
|
+
@@args[:root] = ENV['TASK_DIR'] if ENV['TASK_DIR']
|
33
|
+
|
23
34
|
# puts "args: #{@@args.inspect}"
|
24
35
|
|
25
36
|
if args[:payload_file]
|
@@ -68,5 +79,4 @@ module IronWorker
|
|
68
79
|
return @@args
|
69
80
|
end
|
70
81
|
|
71
|
-
|
72
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iron_core
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- LICENSE
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
52
|
+
- TODO.txt
|
52
53
|
- iron_worker.gemspec
|
53
54
|
- lib/iron_worker.rb
|
54
55
|
- lib/iron_worker/api_client.rb
|