kimchi 0.0.12 → 0.0.13
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/kimchi.gemspec +10 -10
- data/lib/kimchi/version.rb +1 -1
- data/lib/wire.rb +45 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d50d4f46433a4071a80b5fcf8be535a0c7a1b71
|
4
|
+
data.tar.gz: 0310d6289c82dceb4e8ac8e1a176ed3992992943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cdccaf36078dc2f0d4ba0ca5d754322b3a461a2d4129edf69e62de2da9b09f4734cb38c276cef6ff27b8b0e75240a3cb117fa3afee4d159815798ec5c4d3b8f
|
7
|
+
data.tar.gz: 58d20f5e0145a38ffd35e59051313429d837dcf715e371dba9153a95cefda6bf71b3152199233e658cbe8d16292fed7bcaf70dcb980cca2796df0912a6c1341d
|
data/kimchi.gemspec
CHANGED
@@ -4,23 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'kimchi/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'kimchi'
|
8
8
|
spec.version = Kimchi::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Taylor Gautier', 'David Berkman']
|
10
|
+
spec.email = ['robot@icix-usa.com']
|
11
11
|
spec.summary = %q{Various frameworks and utilities to accelerate ICIX bdd tests}
|
12
12
|
spec.description = %q{BDD testing frameworks and utilities}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'http://www.icix.com'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
23
|
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
24
|
+
spec.add_dependency 'uuid'
|
25
|
+
spec.add_dependency 'bunny'
|
26
26
|
end
|
data/lib/kimchi/version.rb
CHANGED
data/lib/wire.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'fiber'
|
3
|
+
require 'uuid'
|
4
|
+
require 'bunny'
|
5
|
+
require 'net/http'
|
6
6
|
|
7
7
|
module Wire
|
8
8
|
|
@@ -15,17 +15,17 @@ module Wire
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# ignore this for any real service call, the http endpoint is evidently incapable of getting this from a header
|
18
|
-
def service= service
|
18
|
+
def service= (service)
|
19
19
|
@service=service
|
20
20
|
end
|
21
21
|
|
22
22
|
# ignore this for any real service call, the http endpoint is evidently incapable of getting this from a header
|
23
|
-
def version= version
|
23
|
+
def version= (version)
|
24
24
|
@version=version
|
25
25
|
end
|
26
26
|
|
27
27
|
def to_json
|
28
|
-
"{
|
28
|
+
"{'endpoint': '#{@name}'" + ((@signature == nil) ? '' : ", 'signature': #{@signature}") + ((@result_type == nil) ? '' : ", 'resultType': '#{@result_type}'") + ((@native_type == nil) ? '' : ", 'nativeType': '#{@native_type}'") + ((@service == nil) ? '' : ", 'service': '#{@service}'") + ((@version == nil) ? '' : ", 'version': '#{@version}'") + '}'
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -40,7 +40,7 @@ module Wire
|
|
40
40
|
@function
|
41
41
|
end
|
42
42
|
|
43
|
-
def contexts= contexts
|
43
|
+
def contexts= (contexts)
|
44
44
|
@contexts=contexts
|
45
45
|
end
|
46
46
|
|
@@ -49,7 +49,7 @@ module Wire
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def to_json
|
52
|
-
"{
|
52
|
+
"{'address': #{@function.to_json}, 'body': #{@arguments.to_json}, 'contexts': #{@contexts.to_json}}"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -94,7 +94,7 @@ module Wire
|
|
94
94
|
@result = result
|
95
95
|
end
|
96
96
|
|
97
|
-
def timeout
|
97
|
+
def timeout
|
98
98
|
raise Timeout::Error.new
|
99
99
|
end
|
100
100
|
end
|
@@ -139,13 +139,13 @@ module Wire
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def transmit_in_only(service_name, version, invocation_signal)
|
142
|
-
initialize_service(service_name).publish(invocation_signal.to_json, :routing_key => "#{version}.2", :headers => {
|
142
|
+
initialize_service(service_name).publish(invocation_signal.to_json, :routing_key => "#{version}.2", :headers => {'x-opt-callerId' => "#{@caller_id}"}, :content_type => 'application/json', :message_id => "#{@uuid.generate}", :timestamp => Time.new.to_i)
|
143
143
|
end
|
144
144
|
|
145
145
|
def transmit(service_name, version, invocation_signal, timeout_seconds)
|
146
146
|
message_id = "#{@uuid.generate}".freeze
|
147
147
|
@message_hash[message_id] = MessageCallback.new(@message_hash, message_id, message = Message.new, timeout_seconds)
|
148
|
-
initialize_service(service_name).publish(invocation_signal.to_json, :routing_key => "#{version}.2", :headers => {
|
148
|
+
initialize_service(service_name).publish(invocation_signal.to_json, :routing_key => "#{version}.2", :headers => {'x-opt-callerId' => "#{@caller_id}"}, :content_type => 'application/json', :message_id => "#{message_id}", :timestamp => Time.new.to_i)
|
149
149
|
|
150
150
|
message
|
151
151
|
end
|
@@ -153,9 +153,11 @@ module Wire
|
|
153
153
|
|
154
154
|
class HttpTransport
|
155
155
|
def initialize (host, port = nil)
|
156
|
+
@type_signatures = {'Fixnum'.freeze => 'I', 'String'.freeze => 'G', 'Array'.freeze => '!Enumerable', 'Hash'.freeze => '!Dictionary'}
|
157
|
+
|
156
158
|
@host = host
|
157
|
-
if
|
158
|
-
@host +=
|
159
|
+
if port != nil
|
160
|
+
@host += ':' + port
|
159
161
|
end
|
160
162
|
end
|
161
163
|
|
@@ -164,7 +166,7 @@ module Wire
|
|
164
166
|
|
165
167
|
begin
|
166
168
|
uri = URI("#{@host}/api/message")
|
167
|
-
headers = {
|
169
|
+
headers = {'Content-Type' => 'application/json'}
|
168
170
|
http = Net::HTTP.new(uri.host, uri.port)
|
169
171
|
http.read_timeout = timeout_seconds
|
170
172
|
|
@@ -190,5 +192,32 @@ module Wire
|
|
190
192
|
|
191
193
|
message
|
192
194
|
end
|
195
|
+
|
196
|
+
# call a service method
|
197
|
+
def call(service, method, args = nil, result_type = nil)
|
198
|
+
function = Function.new(method, (args == nil) ? nil : get_signature(args), result_type)
|
199
|
+
contexts = [
|
200
|
+
{'auth'.freeze => {'user'.freeze => {'id'.freeze => '1'}, 'organization'.freeze => {'id'.freeze => '1'}, 'proxy'.freeze => {'id'.freeze => '-1'}}},
|
201
|
+
{'core'.freeze => {'transaction'.freeze => {'id'.freeze => UUID.new.generate.to_s}, 'stream'.freeze => {'id'.freeze => UUID.new.generate.to_s}}}
|
202
|
+
]
|
203
|
+
|
204
|
+
# puts 'Calling ' + service + '.' + method #+ signature.to_s
|
205
|
+
message = self.transmit(service, '1', InvocationSignal.new(function, args, contexts), 60)
|
206
|
+
result = message.result
|
207
|
+
return result['body']
|
208
|
+
end
|
209
|
+
|
210
|
+
# return array with the type of each argument
|
211
|
+
def get_signature(args)
|
212
|
+
arg_types=[]
|
213
|
+
args.each do |arg|
|
214
|
+
arg_types.push(get_type(arg))
|
215
|
+
end
|
216
|
+
return arg_types
|
217
|
+
end
|
218
|
+
|
219
|
+
def get_type (arg)
|
220
|
+
return @type_signatures[arg.class.to_s]
|
221
|
+
end
|
193
222
|
end
|
194
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kimchi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Gautier
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|