iron_response 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -3
- data/lib/iron_response/batch.rb +27 -1
- data/lib/iron_response/version.rb +2 -2
- data/test/gem_dependency_test.rb +2 -2
- data/test/synopsis_test.rb +2 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -8,12 +8,11 @@ Provides a response object to remote worker scripts. This allows you to write ma
|
|
8
8
|
require "iron_response"
|
9
9
|
|
10
10
|
config = {token: "123", project_id: "456"}
|
11
|
-
batch = IronResponse::Batch.new
|
11
|
+
batch = IronResponse::Batch.new(config)
|
12
12
|
|
13
|
-
batch.auto_update_worker = true
|
14
|
-
batch.config[:iron_io] = config[:iron_io]
|
15
13
|
batch.worker = "test/workers/is_prime.rb"
|
16
14
|
batch.params_array = Array(1..10).map {|i| {number: i}}
|
15
|
+
batch.create_code!(max_concurrency: 4)
|
17
16
|
|
18
17
|
results = batch.run!
|
19
18
|
|
data/lib/iron_response/batch.rb
CHANGED
@@ -19,6 +19,10 @@ module IronResponse
|
|
19
19
|
@worker.split("/").last.split(".rb").first
|
20
20
|
end
|
21
21
|
|
22
|
+
def worker_language
|
23
|
+
is_ruby
|
24
|
+
end
|
25
|
+
|
22
26
|
def run!
|
23
27
|
task_ids = params_array.map do |params|
|
24
28
|
params[:config] = @config
|
@@ -26,6 +30,7 @@ module IronResponse
|
|
26
30
|
end
|
27
31
|
|
28
32
|
task_ids.map do |task_id|
|
33
|
+
p "Fetching response for IronWorker task #{task_id}"
|
29
34
|
get_response_from_task_id(@client.tasks.wait_for(task_id)._id)
|
30
35
|
end
|
31
36
|
end
|
@@ -63,12 +68,33 @@ module IronResponse
|
|
63
68
|
IronResponse::Common.handle_response(response, task_id, @client)
|
64
69
|
end
|
65
70
|
|
71
|
+
def runtime
|
72
|
+
return "ruby" if @worker.end_with?(".rb")
|
73
|
+
return "node" if @worker.end_with?(".js")
|
74
|
+
end
|
75
|
+
|
76
|
+
def prepare_ruby_code(code)
|
77
|
+
code.runtime = "ruby"
|
78
|
+
end
|
79
|
+
|
80
|
+
def prepare_node_code(code)
|
81
|
+
code.runtime = "node"
|
82
|
+
code.dir = "node_modules"
|
83
|
+
code.file = "package.json"
|
84
|
+
end
|
85
|
+
|
66
86
|
def code
|
67
87
|
if @code.nil?
|
68
88
|
@code = IronWorkerNG::Code::Ruby.new(exec: @worker)
|
69
89
|
@code.name = worker_name
|
70
90
|
@code.merge_gem("iron_response", IronResponse::VERSION) # bootstraps the current version with the worker
|
71
|
-
|
91
|
+
|
92
|
+
case runtime
|
93
|
+
when "ruby"
|
94
|
+
prepare_ruby_code(@code)
|
95
|
+
when "node"
|
96
|
+
prepare_node_code(@code)
|
97
|
+
end
|
72
98
|
end
|
73
99
|
|
74
100
|
@code
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module IronResponse
|
2
|
-
VERSION = "0.1.
|
3
|
-
end
|
2
|
+
VERSION = "0.1.5"
|
3
|
+
end
|
data/test/gem_dependency_test.rb
CHANGED
@@ -22,7 +22,7 @@ class GemDependencyTest < MiniTest::Unit::TestCase
|
|
22
22
|
|
23
23
|
results = batch.run!
|
24
24
|
|
25
|
-
binding.pry
|
25
|
+
#binding.pry
|
26
26
|
|
27
27
|
assert_equal batch.params_array.length, results.length
|
28
28
|
|
@@ -58,7 +58,7 @@ class GemDependencyTest < MiniTest::Unit::TestCase
|
|
58
58
|
|
59
59
|
assert_equal batch.params_array.length, results.length
|
60
60
|
|
61
|
-
binding.pry
|
61
|
+
#binding.pry
|
62
62
|
|
63
63
|
results.select! {|r| !r.is_a?(IronResponse::Error)}
|
64
64
|
|
data/test/synopsis_test.rb
CHANGED
@@ -15,7 +15,7 @@ class SynopsisTest < MiniTest::Unit::TestCase
|
|
15
15
|
|
16
16
|
results.select! {|r| !r.is_a?(IronResponse::Error)}
|
17
17
|
|
18
|
-
binding.pry
|
18
|
+
#binding.pry
|
19
19
|
|
20
20
|
assert_equal Array, results.class
|
21
21
|
end
|
@@ -35,7 +35,7 @@ class SynopsisTest < MiniTest::Unit::TestCase
|
|
35
35
|
|
36
36
|
results.select! {|r| !r.is_a?(IronResponse::Error)}
|
37
37
|
|
38
|
-
binding.pry
|
38
|
+
#binding.pry
|
39
39
|
|
40
40
|
assert_equal Array, results.class
|
41
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_response
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
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: 2013-08-
|
12
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: iron_worker_ng
|