tdl-client-ruby 0.12.1 → 0.19.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/.gitignore +1 -0
- data/lib/tdl/client.rb +19 -6
- data/lib/tdl/previous_version.rb +1 -1
- data/lib/tdl/thread_timer.rb +34 -0
- data/lib/tdl/transport/remote_broker.rb +13 -3
- data/tdl-client-ruby.iml +1 -1
- metadata +5 -5
- data/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b5e647e4e638a6cad25dbc4f3b7fdd1955fd4c3
|
4
|
+
data.tar.gz: 6e9f34d8413b93a72aeb50bb1246b38b3c8b6561
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d7a0de04a79f5f8c76a228a3a26885823fba9fd37454a2fd107fdd32eca20883fb12eaf2ac3fa291cc9174f57e5a10c200bc1bd3e9e0164395eb20ab6575812
|
7
|
+
data.tar.gz: 3980492089526e896f596bd86c292ff1bcdff2101adf8bb527ed3aa01f664631b794876f47ed5d0c540794447d681f047e2e63d52c5cc8d873ef8ac322df47f1
|
data/.gitignore
CHANGED
data/lib/tdl/client.rb
CHANGED
@@ -11,30 +11,41 @@ module TDL
|
|
11
11
|
|
12
12
|
class Client
|
13
13
|
|
14
|
-
def initialize(hostname:, port: 61613, unique_id:,
|
14
|
+
def initialize(hostname:, port: 61613, unique_id:, request_timeout_millis: 500)
|
15
15
|
@hostname = hostname
|
16
16
|
@port = port
|
17
17
|
@unique_id = unique_id
|
18
|
-
@
|
18
|
+
@request_timeout_millis = request_timeout_millis
|
19
19
|
@logger = Logging.logger[self]
|
20
|
+
@total_processing_time = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_request_timeout_millis
|
24
|
+
@request_timeout_millis
|
20
25
|
end
|
21
26
|
|
22
27
|
def go_live_with(processing_rules)
|
28
|
+
time1 = Time.now.to_f
|
23
29
|
begin
|
24
30
|
@logger.info 'Starting client.'
|
25
|
-
remote_broker = RemoteBroker.new(@hostname, @port, @unique_id)
|
31
|
+
remote_broker = RemoteBroker.new(@hostname, @port, @unique_id, @request_timeout_millis)
|
26
32
|
remote_broker.subscribe(ApplyProcessingRules.new(processing_rules))
|
27
|
-
|
28
|
-
#DEBT: We should have no timeout here. We could put a special message in the queue
|
29
33
|
@logger.info 'Waiting for requests.'
|
30
|
-
remote_broker.join
|
34
|
+
remote_broker.join
|
31
35
|
@logger.info 'Stopping client.'
|
32
36
|
remote_broker.close
|
37
|
+
|
33
38
|
rescue Exception => e
|
34
39
|
# raise e if ENV['TDL_ENV'] == 'test'
|
35
40
|
@logger.error "There was a problem processing messages. #{e.message}"
|
36
41
|
@logger.error e.backtrace.join("\n")
|
37
42
|
end
|
43
|
+
time2 = Time.now.to_f
|
44
|
+
@total_processing_time = (time2 - time1) * 1000.00
|
45
|
+
end
|
46
|
+
|
47
|
+
def total_processing_time
|
48
|
+
@total_processing_time
|
38
49
|
end
|
39
50
|
|
40
51
|
|
@@ -67,6 +78,8 @@ module TDL
|
|
67
78
|
end
|
68
79
|
|
69
80
|
end
|
81
|
+
|
82
|
+
|
70
83
|
end
|
71
84
|
|
72
85
|
|
data/lib/tdl/previous_version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
class ThreadTimer
|
2
|
+
def initialize(timeout_millis, callback)
|
3
|
+
@timeout_millis=timeout_millis
|
4
|
+
@continue = true
|
5
|
+
@callback = callback
|
6
|
+
@timer_thread = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def start_timer
|
10
|
+
@continue = true
|
11
|
+
@timer_thread = Thread.new { start_timeout }
|
12
|
+
end
|
13
|
+
|
14
|
+
def stop_timer
|
15
|
+
@continue = false
|
16
|
+
@timer_thread.terminate unless @timer_thread.nil?
|
17
|
+
@timer_thread = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def start_timeout
|
23
|
+
total_millis = 0
|
24
|
+
interval_millis = 10
|
25
|
+
while @continue && total_millis < @timeout_millis
|
26
|
+
sleep interval_millis / 1000.00
|
27
|
+
total_millis += interval_millis
|
28
|
+
end
|
29
|
+
|
30
|
+
if total_millis >= @timeout_millis
|
31
|
+
@callback.call
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,15 +1,20 @@
|
|
1
|
+
require_relative '../thread_timer'
|
2
|
+
|
1
3
|
module TDL
|
2
4
|
class RemoteBroker
|
3
|
-
def initialize(hostname, port, unique_id)
|
5
|
+
def initialize(hostname, port, unique_id, request_timeout_millis)
|
4
6
|
@stomp_client = Stomp::Client.new('', '', hostname, port)
|
5
7
|
@unique_id = unique_id
|
6
8
|
@serialization_provider = JSONRPCSerializationProvider.new
|
9
|
+
@timer_thread = ThreadTimer.new(request_timeout_millis, lambda = ->() { close })
|
7
10
|
end
|
8
11
|
|
9
12
|
def subscribe(handling_strategy)
|
10
13
|
@stomp_client.subscribe("/queue/#{@unique_id}.req", {:ack => 'client-individual', 'activemq.prefetchSize' => 1}) do |msg|
|
14
|
+
@timer_thread.stop_timer
|
11
15
|
request = @serialization_provider.deserialize(msg)
|
12
16
|
handling_strategy.process_next_request_from(self, request)
|
17
|
+
@timer_thread.start_timer
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
@@ -19,12 +24,17 @@ module TDL
|
|
19
24
|
@stomp_client.acknowledge(request.original_message)
|
20
25
|
end
|
21
26
|
|
22
|
-
def join
|
23
|
-
@
|
27
|
+
def join
|
28
|
+
@timer_thread.start_timer
|
29
|
+
@stomp_client.join
|
24
30
|
end
|
25
31
|
|
26
32
|
def close
|
27
33
|
@stomp_client.close
|
28
34
|
end
|
35
|
+
|
36
|
+
def closed?
|
37
|
+
@stomp_client.closed?
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
data/tdl-client-ruby.iml
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
<orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.24, rbenv: 2.2.2) [gem]" level="application" />
|
31
31
|
<orderEntry type="library" scope="PROVIDED" name="gherkin (v2.12.2, rbenv: 2.2.2) [gem]" level="application" />
|
32
32
|
<orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.2, rbenv: 2.2.2) [gem]" level="application" />
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.6, rbenv: 2.2.2) [gem]" level="application" />
|
34
34
|
<orderEntry type="library" scope="PROVIDED" name="little-plugger (v1.1.4, rbenv: 2.2.2) [gem]" level="application" />
|
35
35
|
<orderEntry type="library" scope="PROVIDED" name="logging (v2.0.0, rbenv: 2.2.2) [gem]" level="application" />
|
36
36
|
<orderEntry type="library" scope="PROVIDED" name="mime-types (v2.6.1, rbenv: 2.2.2) [gem]" level="application" />
|
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.19.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:
|
11
|
+
date: 2017-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stomp
|
@@ -189,7 +189,6 @@ executables: []
|
|
189
189
|
extensions: []
|
190
190
|
extra_rdoc_files: []
|
191
191
|
files:
|
192
|
-
- ".DS_Store"
|
193
192
|
- ".gitignore"
|
194
193
|
- ".gitmodules"
|
195
194
|
- CODE_OF_CONDUCT.md
|
@@ -212,6 +211,7 @@ files:
|
|
212
211
|
- lib/tdl/processing_rules.rb
|
213
212
|
- lib/tdl/serialization/deserialization_exception.rb
|
214
213
|
- lib/tdl/serialization/json_rpc_serialization_provider.rb
|
214
|
+
- lib/tdl/thread_timer.rb
|
215
215
|
- lib/tdl/transport/remote_broker.rb
|
216
216
|
- lib/tdl/util.rb
|
217
217
|
- release.sh
|
@@ -221,7 +221,7 @@ homepage: https://github.com/julianghionoiu/tdl-client-ruby
|
|
221
221
|
licenses:
|
222
222
|
- GPL-3.0
|
223
223
|
metadata:
|
224
|
-
previous_version: 0.
|
224
|
+
previous_version: 0.12.1
|
225
225
|
post_install_message:
|
226
226
|
rdoc_options: []
|
227
227
|
require_paths:
|
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
238
|
version: '0'
|
239
239
|
requirements: []
|
240
240
|
rubyforge_project:
|
241
|
-
rubygems_version: 2.
|
241
|
+
rubygems_version: 2.6.13
|
242
242
|
signing_key:
|
243
243
|
specification_version: 4
|
244
244
|
summary: A client to connect to the central kata server.
|
data/.DS_Store
DELETED
Binary file
|