rubysdk 0.0.1.pre5 → 0.0.1
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.
- checksums.yaml +4 -4
- data/lib/interface/interface.rb +6 -0
- data/lib/rubysdk.rb +28 -15
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e359c2b1c028748e828f91fb7e152f31045d796b55c7003381398fcc872b51c
|
4
|
+
data.tar.gz: df272ba0b3512d992c15c6131e2943a5e94a386d06f4d09b4b31383bd7326898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b1e46917ad9b81e97551dd950c58f4d889a7aaa1ab49ff8a6cea1ba9be5ce9b3953a68c451c73aa1b8c287cefd52b70bd55bba4a95227c7ce9991b83931781
|
7
|
+
data.tar.gz: aea4b478c9b968c94b7ce636558ed45c595c20e426653564e23a7c6762ac708334771af0efd98bae92bbcb74fab100ddcb18bef063eb32dba1f540ad18ed9c78
|
data/lib/interface/interface.rb
CHANGED
data/lib/rubysdk.rb
CHANGED
@@ -3,6 +3,7 @@ proto_dir = File.join(this_dir, 'proto')
|
|
3
3
|
interface_dir = File.join(this_dir, 'interface')
|
4
4
|
$LOAD_PATH.unshift(proto_dir) unless $LOAD_PATH.include?(proto_dir)
|
5
5
|
$LOAD_PATH.unshift(interface_dir) unless $LOAD_PATH.include?(interface_dir)
|
6
|
+
STDOUT.sync = true
|
6
7
|
|
7
8
|
require 'grpc'
|
8
9
|
require 'grpc/health/checker'
|
@@ -28,7 +29,7 @@ module RubySDK
|
|
28
29
|
def execute_job(job, _call)
|
29
30
|
cjob = nil
|
30
31
|
@cached_jobs.each do |cached_job|
|
31
|
-
cjob = cached_job
|
32
|
+
cjob = cached_job if cached_job.job.unique_id == job.unique_id
|
32
33
|
end
|
33
34
|
if cjob == nil
|
34
35
|
Proto::JobResult.new(failed: true,
|
@@ -39,26 +40,35 @@ module RubySDK
|
|
39
40
|
|
40
41
|
# Transform arguments
|
41
42
|
args = []
|
42
|
-
job.args.
|
43
|
-
|
43
|
+
if !job.args.empty?
|
44
|
+
job.args.each do |arg|
|
45
|
+
new_arg = Proto::Argument.new(key: arg.key,
|
44
46
|
value: arg.value)
|
45
|
-
|
47
|
+
args.push new_arg
|
48
|
+
end
|
46
49
|
end
|
47
50
|
|
48
51
|
# Execute job
|
49
|
-
|
52
|
+
job_failed = false
|
53
|
+
exit_pipeline = false
|
54
|
+
message = ""
|
55
|
+
unique_id = 0
|
50
56
|
begin
|
51
|
-
|
57
|
+
cjob.handler.call(args)
|
52
58
|
rescue => e
|
53
59
|
# Check if job wants to force exit pipeline.
|
54
60
|
# We will exit the pipeline but not mark it as 'failed'.
|
55
|
-
|
61
|
+
job_failed = true if e == ErrorExitPipeline
|
56
62
|
|
57
63
|
# Set log message and job id
|
58
|
-
|
59
|
-
|
60
|
-
|
64
|
+
exit_pipeline = true
|
65
|
+
message = e.message
|
66
|
+
unique_id = job.job.unique_id
|
61
67
|
end
|
68
|
+
Proto::JobResult.new(unique_id: unique_id,
|
69
|
+
failed: job_failed,
|
70
|
+
exit_pipeline: exit_pipeline,
|
71
|
+
message: message)
|
62
72
|
end
|
63
73
|
end
|
64
74
|
|
@@ -81,6 +91,11 @@ module RubySDK
|
|
81
91
|
args = []
|
82
92
|
if job.args != nil
|
83
93
|
job.args.each do |arg|
|
94
|
+
# Description and Value are optional.
|
95
|
+
# Set default values for those.
|
96
|
+
arg.desc = "" if arg.desc == nil
|
97
|
+
arg.value = "" if arg.value == nil
|
98
|
+
|
84
99
|
trans_arg = Proto::Argument.new(description: arg.desc,
|
85
100
|
type: arg.type,
|
86
101
|
key: arg.key,
|
@@ -104,7 +119,7 @@ module RubySDK
|
|
104
119
|
dep_found = false
|
105
120
|
jobs.each do |curr_job|
|
106
121
|
if curr_job.title.casecmp(dep_job) == 0
|
107
|
-
proto_job.dependson
|
122
|
+
proto_job.dependson.push FNV.new.fnv1a_32(curr_job.title)
|
108
123
|
dep_found = true
|
109
124
|
break
|
110
125
|
end
|
@@ -159,7 +174,7 @@ module RubySDK
|
|
159
174
|
)
|
160
175
|
|
161
176
|
# Register gRPC server and handle.
|
162
|
-
host = '
|
177
|
+
host = '127.0.0.1'
|
163
178
|
s = GRPC::RpcServer.new
|
164
179
|
port = s.add_http2_port(host+':0', credentials)
|
165
180
|
s.handle(GRPCServer.new(cached_jobs))
|
@@ -167,9 +182,7 @@ module RubySDK
|
|
167
182
|
|
168
183
|
# Output the address and service name to stdout.
|
169
184
|
# hashicorp go-plugin will use that to establish a connection.
|
170
|
-
puts "1|2|tcp|#{host}:#{port}|grpc"
|
171
|
-
GRPC.logger.info("1|2|tcp|#{host}:#{port}|grpc")
|
172
|
-
STDOUT.sync = true
|
185
|
+
STDOUT.puts "1|2|tcp|#{host}:#{port}|grpc"
|
173
186
|
|
174
187
|
s.run_till_terminated
|
175
188
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Vocks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grpc
|
@@ -77,9 +77,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
85
|
rubygems_version: 2.7.6
|