tdl-client-ruby 0.29.4 → 0.29.6
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/.github/workflows/release.yml +1 -1
- data/README.md +1 -1
- data/lib/tdl/audit/audit_stream.rb +38 -0
- data/lib/tdl/queue/abstractions/request.rb +9 -9
- data/lib/tdl/queue/queue_based_implementation_runner.rb +26 -41
- data/lib/tdl/queue/serialization/json_rpc_serialization_provider.rb +1 -1
- data/tdl-client-ruby.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8240a8e5d865fc79fbc846b2872eb992f178f4717c295e0f30d2fdfc06c57c55
|
4
|
+
data.tar.gz: 3c905b83fb9ff15a3fb7ec49f3fac1d3d0b3fda582ca1dbd5f454bdf89253a58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b40be2440d4b08b2e2be0fad8bba399ca207b60d104bc9e4bddb1883f2b7226aad62980de69176de3204a982732e75ef4bb48bdb0aa5ca9d2f79310db6ad170
|
7
|
+
data.tar.gz: 5e1d9468d03aa8ad7099e808cbc0472d291e28132a33baab60c5d78da316195203c6bc1e1d25609da6abd1f7858f27366e0da7e3befaa33476dbd2cc6f655d13
|
data/README.md
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
class AuditStream
|
2
|
+
def initialize
|
3
|
+
@logger = Logging.logger[self]
|
4
|
+
start_line
|
5
|
+
end
|
6
|
+
|
7
|
+
def start_line
|
8
|
+
@str = ''
|
9
|
+
end
|
10
|
+
|
11
|
+
def log_request(request)
|
12
|
+
params_as_string = TDL::PresentationUtil.to_displayable_request(request.params)
|
13
|
+
text = "id = #{request.id}, req = #{request.method}(#{params_as_string})"
|
14
|
+
|
15
|
+
if not text.empty? and @str.length > 0
|
16
|
+
@str << ', '
|
17
|
+
end
|
18
|
+
@str << text
|
19
|
+
end
|
20
|
+
|
21
|
+
def log_response(response)
|
22
|
+
if response.instance_variable_defined?(:@result)
|
23
|
+
representation = TDL::PresentationUtil.to_displayable_response(response.result)
|
24
|
+
text = "resp = #{representation}"
|
25
|
+
else
|
26
|
+
text = "error = #{response.message}" + ", (NOT PUBLISHED)"
|
27
|
+
end
|
28
|
+
|
29
|
+
if not text.empty? and @str.length > 0
|
30
|
+
@str << ', '
|
31
|
+
end
|
32
|
+
@str << text
|
33
|
+
end
|
34
|
+
|
35
|
+
def end_line
|
36
|
+
@logger.info @str
|
37
|
+
end
|
38
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module TDL
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
Request = Struct.new(:original_message, :id, :method, :params) do
|
3
|
+
def self.deserialize(original_message, request_data)
|
4
|
+
new(
|
5
|
+
original_message,
|
6
|
+
request_data.fetch('id'),
|
7
|
+
request_data.fetch('method'),
|
8
|
+
request_data.fetch('params')
|
9
|
+
)
|
10
10
|
end
|
11
11
|
end
|
12
|
-
end
|
12
|
+
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
require 'logging'
|
2
|
+
require 'ostruct'
|
3
|
+
|
2
4
|
require 'tdl/audit/presentation_utils'
|
3
5
|
require 'tdl/queue/processing_rules'
|
4
6
|
require 'tdl/queue/transport/remote_broker'
|
7
|
+
require 'tdl/audit/audit_stream'
|
8
|
+
|
5
9
|
|
6
10
|
module TDL
|
7
11
|
class QueueBasedImplementationRunner
|
@@ -52,13 +56,15 @@ module TDL
|
|
52
56
|
@logger = Logging.logger[self]
|
53
57
|
@audit = AuditStream.new
|
54
58
|
end
|
55
|
-
|
59
|
+
|
60
|
+
|
56
61
|
def process_next_request_from(remote_broker, request)
|
57
62
|
@audit.start_line
|
58
63
|
@audit.log_request(request)
|
59
64
|
|
60
65
|
# Obtain response from user
|
61
|
-
|
66
|
+
request_as_object = ApplyProcessingRules.request_as_object(request)
|
67
|
+
response = @processing_rules.get_response_for(request_as_object)
|
62
68
|
@audit.log_response(response)
|
63
69
|
|
64
70
|
# Act
|
@@ -84,47 +90,26 @@ module TDL
|
|
84
90
|
# Do nothing
|
85
91
|
end
|
86
92
|
end
|
93
|
+
|
94
|
+
def self.request_as_object(request)
|
95
|
+
Request.new(request.original_message,
|
96
|
+
request.id,
|
97
|
+
request.method,
|
98
|
+
ApplyProcessingRules.to_openstruct(request.params))
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.to_openstruct(obj)
|
102
|
+
case obj
|
103
|
+
when Hash
|
104
|
+
OpenStruct.new(obj.transform_values { |v| to_openstruct(v) })
|
105
|
+
when Array
|
106
|
+
obj.map { |e| to_openstruct(e) }
|
107
|
+
else
|
108
|
+
obj
|
109
|
+
end
|
110
|
+
end
|
87
111
|
end
|
88
112
|
end
|
89
113
|
end
|
90
114
|
|
91
|
-
class AuditStream
|
92
|
-
|
93
|
-
def initialize
|
94
|
-
@logger = Logging.logger[self]
|
95
|
-
start_line
|
96
|
-
end
|
97
115
|
|
98
|
-
def start_line
|
99
|
-
@str = ''
|
100
|
-
end
|
101
|
-
|
102
|
-
def log_request(request)
|
103
|
-
params_as_string = TDL::PresentationUtil.to_displayable_request(request.params)
|
104
|
-
text = "id = #{request.id}, req = #{request.method}(#{params_as_string})"
|
105
|
-
|
106
|
-
if not text.empty? and @str.length > 0
|
107
|
-
@str << ', '
|
108
|
-
end
|
109
|
-
@str << text
|
110
|
-
end
|
111
|
-
|
112
|
-
def log_response(response)
|
113
|
-
if response.instance_variable_defined?(:@result)
|
114
|
-
representation = TDL::PresentationUtil.to_displayable_response(response.result)
|
115
|
-
text = "resp = #{representation}"
|
116
|
-
else
|
117
|
-
text = "error = #{response.message}" + ", (NOT PUBLISHED)"
|
118
|
-
end
|
119
|
-
|
120
|
-
if not text.empty? and @str.length > 0
|
121
|
-
@str << ', '
|
122
|
-
end
|
123
|
-
@str << text
|
124
|
-
end
|
125
|
-
|
126
|
-
def end_line
|
127
|
-
@logger.info @str
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
@@ -11,7 +11,7 @@ module TDL
|
|
11
11
|
def deserialize(msg)
|
12
12
|
begin
|
13
13
|
request_data = JSON.parse(msg.body.gsub("\n", '\n'))
|
14
|
-
Request.
|
14
|
+
Request.deserialize(msg, request_data)
|
15
15
|
rescue Exception => e
|
16
16
|
raise DeserializationException,'Invalid message format: '+msg.body, e.backtrace
|
17
17
|
end
|
data/tdl-client-ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdl-client-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.29.
|
4
|
+
version: 0.29.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Ghionoiu
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-30 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: stomp
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- README.md
|
198
198
|
- Rakefile
|
199
199
|
- lib/tdl.rb
|
200
|
+
- lib/tdl/audit/audit_stream.rb
|
200
201
|
- lib/tdl/audit/console_audit_stream.rb
|
201
202
|
- lib/tdl/audit/presentation_utils.rb
|
202
203
|
- lib/tdl/queue/abstractions/processing_rule.rb
|