tdl-client-ruby 0.20.2 → 0.20.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d081f8262e8af9cd33df7f7896c6bfcb9a9b917d
4
- data.tar.gz: 4c29a8cf4324c137277e73a20adc4fcd1829dda4
3
+ metadata.gz: fa06f4cfebda29d3cc02c23b061f6726e72f0038
4
+ data.tar.gz: 480a07f019c1bd689dd3a4f5b5b5a3fd5c6c68cb
5
5
  SHA512:
6
- metadata.gz: f17c3a35370537e33ab4faee10ae67fce134003aaa3e195bbb5c9d59ccfd442fefa3968c9825e85d35e5f9b61d238a5e353d0d848998eca22ce73aa7110f5a0a
7
- data.tar.gz: b09c217c7c76fd3acec43651e97783d3f2c1a2c527cf78d81bef4f8e62797481c7e8a197e01193922b8761f2c9f9faae9b5e01f53fae836da549f3c5e3754f59
6
+ metadata.gz: 743ceb9a9eacbd64347094369fa7e710dfb0d2b9ab49dd6f61168acb1e4e18d4c88080d5179de8372fc02a6b80564b889833aeda6b3bc3c15aa2373d418fa45c
7
+ data.tar.gz: 51fe054e7c3d2100d3d7fe1b5ab2cbb2fd09a55079a6d8833c29344fb210fd5c6a282b89b5e72273a4f0209e24165629c6ba2c9e6527a3fc6cd623411d77152a
data/lib/tdl.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'tdl/queue/client'
2
1
  require 'tdl/queue/implementation_runner_config'
3
2
  require 'tdl/queue/queue_based_implementation_runner'
4
3
  require 'tdl/queue/queue_based_implementation_runner_builder'
@@ -1,4 +1,4 @@
1
1
  module TDL
2
- PREVIOUS_VERSION = '0.20.1'
2
+ PREVIOUS_VERSION = '0.20.3'
3
3
  # the current MAJOR.MINOR version is dynamically computed from the version of the Spec
4
4
  end
@@ -1,6 +1,6 @@
1
1
  require 'logging'
2
-
3
2
  require 'tdl/queue/processing_rules'
3
+ require 'tdl/queue/transport/remote_broker'
4
4
 
5
5
  module TDL
6
6
  class QueueBasedImplementationRunner
@@ -73,3 +73,29 @@ module TDL
73
73
  end
74
74
  end
75
75
  end
76
+
77
+ class AuditStream
78
+
79
+ def initialize
80
+ @logger = Logging.logger[self]
81
+ start_line
82
+ end
83
+
84
+ def start_line
85
+ @str = ''
86
+ end
87
+
88
+ def log(auditable)
89
+ text = auditable.audit_text
90
+ if not text.empty? and @str.length > 0
91
+ @str << ', '
92
+ end
93
+
94
+ @str << text
95
+ end
96
+
97
+ def end_line
98
+ @logger.info @str
99
+ end
100
+
101
+ end
@@ -1,4 +1,6 @@
1
+ require 'stomp'
1
2
  require 'tdl/thread_timer'
3
+ require 'tdl/queue/serialization/json_rpc_serialization_provider'
2
4
 
3
5
  module TDL
4
6
  class RemoteBroker
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.20.2
4
+ version: 0.20.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Ghionoiu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-06 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stomp
@@ -210,7 +210,6 @@ files:
210
210
  - LICENSE
211
211
  - README.md
212
212
  - Rakefile
213
- - examples/add_numbers.rb
214
213
  - lib/tdl.rb
215
214
  - lib/tdl/audit/console_audit_stream.rb
216
215
  - lib/tdl/previous_version.rb
@@ -222,7 +221,6 @@ files:
222
221
  - lib/tdl/queue/actions/publish_action.rb
223
222
  - lib/tdl/queue/actions/publish_and_stop_action.rb
224
223
  - lib/tdl/queue/actions/stop_action.rb
225
- - lib/tdl/queue/client.rb
226
224
  - lib/tdl/queue/implementation_runner_config.rb
227
225
  - lib/tdl/queue/processing_rules.rb
228
226
  - lib/tdl/queue/queue_based_implementation_runner.rb
@@ -245,7 +243,7 @@ homepage: https://github.com/julianghionoiu/tdl-client-ruby
245
243
  licenses:
246
244
  - GPL-3.0
247
245
  metadata:
248
- previous_version: 0.20.1
246
+ previous_version: 0.20.3
249
247
  post_install_message:
250
248
  rdoc_options: []
251
249
  require_paths:
@@ -1,31 +0,0 @@
1
- require 'tdl'
2
- require 'logging'
3
-
4
- Logging.logger.root.appenders = Logging.appenders.stdout
5
- Logging.logger.root.level = :info
6
-
7
-
8
- def run_client
9
- client = TDL::Client.new( hostname: 'localhost', port: 61613, unique_id: 'julian@example.com')
10
- include TDL::ClientActions
11
- rules = TDL::ProcessingRules.new
12
- rules.on('display_description').call(method(:display)).then(publish)
13
- rules.on('sum').call(method(:sum)).then(publish)
14
- rules.on('end_round').call(lambda { 'OK' }).then(publish_and_stop)
15
-
16
- # puts processing_rules.to_yaml
17
-
18
- client.go_live_with(rules)
19
- end
20
-
21
- def display(round, description)
22
- puts "#{round} = #{description}"
23
- 'OK'
24
- end
25
-
26
- def sum(x, y)
27
- x + y
28
- end
29
-
30
-
31
- run_client
@@ -1,112 +0,0 @@
1
- require 'stomp'
2
- require 'logging'
3
-
4
- require 'tdl/queue/transport/remote_broker'
5
- require 'tdl/queue/processing_rules'
6
- require 'tdl/queue/actions/stop_action'
7
-
8
- require 'tdl/queue/serialization/json_rpc_serialization_provider'
9
-
10
- module TDL
11
-
12
- class Client
13
-
14
- def initialize(hostname:, port: 61613, unique_id:, request_timeout_millis: 500)
15
- @hostname = hostname
16
- @port = port
17
- @unique_id = unique_id
18
- @request_timeout_millis = request_timeout_millis
19
- @logger = Logging.logger[self]
20
- @total_processing_time = nil
21
- end
22
-
23
- def get_request_timeout_millis
24
- @request_timeout_millis
25
- end
26
-
27
- def go_live_with(processing_rules)
28
- time1 = Time.now.to_f
29
- begin
30
- @logger.info 'Starting client.'
31
- remote_broker = RemoteBroker.new(@hostname, @port, @unique_id, @request_timeout_millis)
32
- remote_broker.subscribe(ApplyProcessingRules.new(processing_rules))
33
- @logger.info 'Waiting for requests.'
34
- remote_broker.join
35
- @logger.info 'Stopping client.'
36
-
37
- rescue Exception => e
38
- # raise e if ENV['TDL_ENV'] == 'test'
39
- @logger.error "There was a problem processing messages. #{e.message}"
40
- @logger.error e.backtrace.join("\n")
41
- end
42
- time2 = Time.now.to_f
43
- @total_processing_time = (time2 - time1) * 1000.00
44
- end
45
-
46
- def total_processing_time
47
- @total_processing_time
48
- end
49
-
50
-
51
- #~~~~ Queue handling policies
52
-
53
- class ApplyProcessingRules
54
-
55
- def initialize(processing_rules)
56
- @processing_rules = processing_rules
57
- @logger = Logging.logger[self]
58
- @audit = AuditStream.new
59
- end
60
-
61
- def process_next_request_from(remote_broker, request)
62
- @audit.start_line
63
- @audit.log(request)
64
-
65
- # Obtain response from user
66
- response = @processing_rules.get_response_for(request)
67
- @audit.log(response)
68
-
69
- # Obtain action
70
- client_action = response.client_action
71
-
72
- # Act
73
- client_action.after_response(remote_broker, request, response)
74
- @audit.log(client_action)
75
- @audit.end_line
76
- client_action.prepare_for_next_request(remote_broker)
77
- end
78
-
79
- end
80
-
81
-
82
- end
83
-
84
-
85
- # ~~~~ Utils
86
-
87
- class AuditStream
88
-
89
- def initialize
90
- @logger = Logging.logger[self]
91
- start_line
92
- end
93
-
94
- def start_line
95
- @str = ''
96
- end
97
-
98
- def log(auditable)
99
- text = auditable.audit_text
100
- if not text.empty? and @str.length > 0
101
- @str << ', '
102
- end
103
-
104
- @str << text
105
- end
106
-
107
- def end_line
108
- @logger.info @str
109
- end
110
-
111
- end
112
- end