tdl-client-ruby 0.6.2 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tdl.rb +1 -2
- data/lib/tdl/abstractions/request.rb +8 -4
- data/lib/tdl/abstractions/response/valid_response.rb +3 -1
- data/lib/tdl/client.rb +1 -1
- data/lib/tdl/processing_rules.rb +2 -2
- data/lib/tdl/serialization/json_rpc_serialization_provider.rb +2 -1
- data/lib/tdl/util.rb +22 -0
- 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: 692ce8021fc9ee93c4beb5d2ccf53702b357a852
|
4
|
+
data.tar.gz: bd4c39075d37f2585f9e2d08283094b074b59a42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5390ada98e61d5d533525df561e00f26379c9ced6d966f794beb861532f2176d8dc7ae7a906aa5da0786b2c16675736bba3de07ee807b843fbe8c93b343e689
|
7
|
+
data.tar.gz: 6ecb31247e27e216db9d5dbc5a747e5ea298a69b0ec6e1008c0af3d9d846d4f3f50ea7b8ec520c8b315a52f44b35eb493301416a6ec6a8d1d1dc2e739aed0bb8
|
data/lib/tdl.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
+
require 'tdl/util'
|
2
|
+
|
1
3
|
module TDL
|
2
4
|
class Request
|
3
5
|
attr_reader :original_message, :id, :method, :params
|
4
6
|
|
5
7
|
def initialize(original_message, request_data)
|
6
8
|
@original_message = original_message
|
7
|
-
@id = request_data
|
8
|
-
@method = request_data
|
9
|
-
@params = request_data
|
9
|
+
@id = request_data.fetch('id')
|
10
|
+
@method = request_data.fetch('method')
|
11
|
+
@params = request_data.fetch('params')
|
10
12
|
end
|
11
13
|
|
12
14
|
def audit_text
|
13
|
-
"id = #{
|
15
|
+
"id = #{id}, req = #{method}(#{params.map{ |param|
|
16
|
+
TDL::Util.compress_data(param)
|
17
|
+
}.join(', ')})"
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
data/lib/tdl/client.rb
CHANGED
@@ -6,7 +6,6 @@ require 'tdl/processing_rules'
|
|
6
6
|
require 'tdl/actions/stop_action'
|
7
7
|
|
8
8
|
require 'tdl/serialization/json_rpc_serialization_provider'
|
9
|
-
|
10
9
|
module TDL
|
11
10
|
|
12
11
|
class Client
|
@@ -29,6 +28,7 @@ module TDL
|
|
29
28
|
@logger.info 'Stopping client.'
|
30
29
|
remote_broker.close
|
31
30
|
rescue Exception => e
|
31
|
+
# raise e if ENV['TDL_ENV'] == 'test'
|
32
32
|
@logger.error "There was a problem processing messages. #{e.message}"
|
33
33
|
@logger.error e.backtrace.join("\n")
|
34
34
|
end
|
data/lib/tdl/processing_rules.rb
CHANGED
@@ -45,7 +45,7 @@ module TDL
|
|
45
45
|
if @rules.has_key?(request.method)
|
46
46
|
processing_rule = @rules[request.method]
|
47
47
|
else
|
48
|
-
message = "method
|
48
|
+
message = "\"method '#{request.method}' did not match any processing rule\""
|
49
49
|
@logger.warn(message)
|
50
50
|
return FatalErrorResponse.new(message)
|
51
51
|
end
|
@@ -56,7 +56,7 @@ module TDL
|
|
56
56
|
|
57
57
|
return ValidResponse.new(request.id, result, processing_rule.client_action)
|
58
58
|
rescue Exception => e
|
59
|
-
message = 'user implementation raised exception'
|
59
|
+
message = '"user implementation raised exception"'
|
60
60
|
@logger.warn("#{message}, #{e.message}")
|
61
61
|
@logger.warn e.backtrace.join("\n")
|
62
62
|
return FatalErrorResponse.new(message)
|
@@ -10,9 +10,10 @@ module TDL
|
|
10
10
|
|
11
11
|
def deserialize(msg)
|
12
12
|
begin
|
13
|
-
request_data = JSON.parse(msg.body)
|
13
|
+
request_data = JSON.parse(msg.body.gsub("\n", '\n'))
|
14
14
|
Request.new(msg, request_data)
|
15
15
|
rescue Exception => e
|
16
|
+
raise e if ENV['TDL_ENV'] == 'test'
|
16
17
|
raise DeserializationException,'Invalid message format', e.backtrace
|
17
18
|
end
|
18
19
|
end
|
data/lib/tdl/util.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module TDL
|
2
|
+
module Util
|
3
|
+
def self.compress_text(text)
|
4
|
+
# DEBT compress text should not add quotes
|
5
|
+
top_line, *remaing_content = text.split("\n")
|
6
|
+
if remaing_content
|
7
|
+
lines_remaining = remaing_content.size
|
8
|
+
"\"#{top_line} .. ( #{lines_remaining} more line#{ 's' if lines_remaining != 1 } )\""
|
9
|
+
else
|
10
|
+
"\"#{top_line}\""
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.compress_data(data)
|
15
|
+
if data.respond_to?(:split)
|
16
|
+
"#{TDL::Util.compress_text(data)}"
|
17
|
+
else
|
18
|
+
"#{data}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdl-client-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Ghionoiu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stomp
|
@@ -212,6 +212,7 @@ files:
|
|
212
212
|
- lib/tdl/serialization/deserialization_exception.rb
|
213
213
|
- lib/tdl/serialization/json_rpc_serialization_provider.rb
|
214
214
|
- lib/tdl/transport/remote_broker.rb
|
215
|
+
- lib/tdl/util.rb
|
215
216
|
- release.sh
|
216
217
|
- tdl-client-ruby.gemspec
|
217
218
|
- tdl-client-ruby.iml
|