tdl-client-ruby 0.22.1 → 0.25.1

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
  SHA256:
3
- metadata.gz: c010e01bbf54e96598f837d6dbad4d2522e8ece8c359a934e6d248fb73ac40da
4
- data.tar.gz: ab556e467482c6a227d55e8425ed338bf2899856b114617f96e9c49cb53eebce
3
+ metadata.gz: eda7242d36229737d1741218dd19edd41df6ae474812d331db1988fa038c1196
4
+ data.tar.gz: df6675ee0971590ed474ede8bf2e5ec22c1669ced60da14bad725c792c4f4ff6
5
5
  SHA512:
6
- metadata.gz: ec89c3029e6d36f119c390a83816762d3276f421622d3386c0358bd427583cd8f71fbc8ed9601133b6e38adf08387e0a903343d72c5d6cc25aaa3d39c8dd0a3c
7
- data.tar.gz: bdf125e5e75c8ad5c6dd90fa38e1a42170931f8b72230c22ccda1c56e3d82a9228908781bc3a854edbf6c6ae72e26f9e8b04d234fd2c6ecce7655210581b51b9
6
+ metadata.gz: 05f39cfbb1c9613d7dc91d0a937c895a0b6429054d2ae24cb50c6785407954f74ab3e0afef7f0a51ea49ce3c84bd60618e5b64c3f49f17111eb62ce167fac082
7
+ data.tar.gz: 4f614415157a702d1a26c2654cd8b188978c1a71615e84550b16e8d0e33ee656c911352f4019048cd0fc11119487af972805d74a37a4c5099cb4883d40c8b541
data/README.md CHANGED
@@ -5,22 +5,75 @@
5
5
 
6
6
  # tdl-client-ruby
7
7
 
8
+ ### Submodules
9
+
10
+ Project contains submodules as mentioned in the `.gitmodules` file:
11
+
12
+ - broker
13
+ - tdl/client-spec (gets cloned into features/spec)
14
+ - wiremock
15
+
16
+ Use the below command to update the submodules of the project:
17
+
8
18
  ```
9
- # Install RVM
19
+ git submodule update --init
20
+ ```
21
+
22
+ ### Getting started
23
+
24
+ Ruby client to connect to the central kata server.
25
+
26
+ ### Installing
27
+
28
+ #### Install RVM
29
+ ```bash
10
30
  curl -sSL https://get.rvm.io | bash -s stable
11
- echo 'source /Users/julianghionoiu/.rvm/scripts/rvm' >> .bash_profile
31
+ echo "source $HOME/.rvm/scripts/rvm" >> .bash_profile
32
+ ```
12
33
 
13
- # Install ruby
34
+ #### Install ruby
35
+ ```bash
14
36
  rvm install ruby-2.2.2
15
37
  rvm use ruby-2.2.2
38
+ ```
16
39
 
17
- # Install bundler
40
+ #### Install bundler
41
+ ```bash
18
42
  gem install bundler
19
43
  ```
20
44
 
21
- # Installing
45
+ #### Install coveralls
46
+ ```bash
47
+ gem install coveralls
48
+ ```
49
+
50
+ #### Install cucumber
51
+ ```bash
52
+ gem install cucumber
53
+ ```
54
+
55
+ #### Install all the gems in the project
56
+ ```bash
57
+ bundle install
58
+ ```
59
+
60
+ #### Manual
61
+
62
+ Stopping the wiremocks and broker services would be the same, using the `stop` command instead of the `start` command.
63
+
64
+ #### Automatic (via script)
65
+
66
+ Start and stop the wiremocks and broker services with the below:
67
+
68
+ ```bash
69
+ ./startExternalDependencies.sh
70
+ ```
22
71
 
23
- # Testing
72
+ ```bash
73
+ ./stopExternalDependencies.sh
74
+ ```
75
+
76
+ ### Testing
24
77
 
25
78
  All test require the ActiveMQ broker to be started.
26
79
  The following commands are available for the broker.
@@ -31,11 +84,17 @@ python wiremock/wiremock-wrapper.py start 41375
31
84
  python wiremock/wiremock-wrapper.py start 8222
32
85
  ```
33
86
 
87
+ or
88
+
89
+ ```bash
90
+ ./startExternalDependencies.sh
91
+ ```
92
+
34
93
  Run tests with `rake features`.
35
94
  To run a single scenario execute `cucumber path/to/file.feature:line_no`
36
95
  Recommendation is to use the cucumber command instead of rake always outside of CI.
37
96
 
38
- # Cleanup
97
+ ### Cleanup
39
98
 
40
99
  Stop external dependencies
41
100
  ```
@@ -44,10 +103,16 @@ python wiremock/wiremock-wrapper.py stop 41375
44
103
  python wiremock/wiremock-wrapper.py stop 8222
45
104
  ```
46
105
 
106
+ or
47
107
 
48
- # To release
108
+ ```bash
109
+ ./stopExternalDependencies.sh
110
+ ```
111
+
112
+
113
+ ## To release
49
114
 
50
115
  Run
51
116
  ```
52
117
  ./release.sh
53
- ```
118
+ ```
@@ -1,4 +1,4 @@
1
1
  module TDL
2
- PREVIOUS_VERSION = '0.21.1'
2
+ PREVIOUS_VERSION = '0.22.1'
3
3
  # the current MAJOR.MINOR version is dynamically computed from the version of the Spec
4
4
  end
@@ -1,10 +1,9 @@
1
1
  module TDL
2
2
  class ProcessingRule
3
- attr_reader :user_implementation, :client_action
3
+ attr_reader :user_implementation
4
4
 
5
- def initialize(user_implementation, client_action)
5
+ def initialize(user_implementation)
6
6
  @user_implementation = user_implementation
7
- @client_action = client_action
8
7
  end
9
8
  end
10
9
  end
@@ -1,14 +1,8 @@
1
- require 'tdl/queue/actions/stop_action'
2
-
3
1
  module TDL
4
2
  class FatalErrorResponse
5
3
 
6
4
  def initialize(message)
7
- @message = message
8
- end
9
-
10
- def client_action
11
- StopAction.new
5
+ @message = message + ", (NOT PUBLISHED)"
12
6
  end
13
7
 
14
8
  def audit_text
@@ -2,12 +2,11 @@ require 'tdl/util'
2
2
 
3
3
  module TDL
4
4
  class ValidResponse
5
- attr_reader :id, :result, :client_action
5
+ attr_reader :id, :result
6
6
 
7
- def initialize(id, result, client_action)
7
+ def initialize(id, result)
8
8
  @id = id
9
9
  @result = result
10
- @client_action = client_action
11
10
  end
12
11
 
13
12
  def to_h
@@ -8,6 +8,8 @@ module TDL
8
8
  @port = 61613
9
9
  @time_to_wait_for_requests = 500
10
10
  @audit_stream = ConsoleAuditStream.new
11
+ @request_queue_name = ''
12
+ @response_queue_name = ''
11
13
  end
12
14
 
13
15
  def set_hostname(hostname)
@@ -20,8 +22,13 @@ module TDL
20
22
  self
21
23
  end
22
24
 
23
- def set_unique_id(unique_id)
24
- @unique_id = unique_id
25
+ def set_request_queue_name(queue_name)
26
+ @request_queue_name = queue_name
27
+ self
28
+ end
29
+
30
+ def set_response_queue_name(queue_name)
31
+ @response_queue_name = queue_name
25
32
  self
26
33
  end
27
34
 
@@ -43,8 +50,12 @@ module TDL
43
50
  @port
44
51
  end
45
52
 
46
- def get_unique_id
47
- @unique_id
53
+ def get_request_queue_name
54
+ @request_queue_name
55
+ end
56
+
57
+ def get_response_queue_name
58
+ @response_queue_name
48
59
  end
49
60
 
50
61
  def get_time_to_wait_for_requests
@@ -1,7 +1,6 @@
1
1
  require 'tdl/queue/abstractions/processing_rule'
2
2
  require 'tdl/queue/abstractions/response/fatal_error_response'
3
3
  require 'tdl/queue/abstractions/response/valid_response'
4
- require 'tdl/queue/actions/client_actions'
5
4
 
6
5
  module TDL
7
6
  class ProcessingRules
@@ -13,8 +12,8 @@ module TDL
13
12
 
14
13
  # ~~~~ Builders
15
14
 
16
- def add(method_name, user_implementation, client_action)
17
- @rules[method_name] = ProcessingRule.new(user_implementation, client_action)
15
+ def add(method_name, user_implementation)
16
+ @rules[method_name] = ProcessingRule.new(user_implementation)
18
17
  end
19
18
 
20
19
  def on(method_name)
@@ -33,8 +32,8 @@ module TDL
33
32
  self
34
33
  end
35
34
 
36
- def then(client_action)
37
- @instance.add(@method_name, @user_implementation, client_action)
35
+ def build()
36
+ @instance.add(@method_name, @user_implementation)
38
37
  end
39
38
  end
40
39
 
@@ -54,7 +53,7 @@ module TDL
54
53
  user_implementation = processing_rule.user_implementation
55
54
  result = user_implementation.call(*request.params)
56
55
 
57
- return ValidResponse.new(request.id, result, processing_rule.client_action)
56
+ return ValidResponse.new(request.id, result)
58
57
  rescue Exception => e
59
58
  message = '"user implementation raised exception"'
60
59
  @logger.warn("#{message}, #{e.message}")
@@ -19,7 +19,8 @@ module TDL
19
19
  remote_broker = RemoteBroker.new(
20
20
  @config.get_hostname,
21
21
  @config.get_port,
22
- @config.get_unique_id,
22
+ @config.get_request_queue_name,
23
+ @config.get_response_queue_name,
23
24
  @config.get_time_to_wait_for_requests)
24
25
  remote_broker.subscribe(ApplyProcessingRules.new(@deploy_processing_rules))
25
26
  @logger.info 'Waiting for requests.'
@@ -59,17 +60,30 @@ module TDL
59
60
  # Obtain response from user
60
61
  response = @processing_rules.get_response_for(request)
61
62
  @audit.log(response)
62
-
63
- # Obtain action
64
- client_action = response.client_action
65
-
63
+
66
64
  # Act
67
- client_action.after_response(remote_broker, request, response)
68
- @audit.log(client_action)
65
+ after_response(remote_broker, request, response)
66
+
69
67
  @audit.end_line
70
- client_action.prepare_for_next_request(remote_broker)
68
+
69
+ prepare_for_next_request(remote_broker, response)
70
+ end
71
+
72
+ def after_response(remote_broker, request, response)
73
+ if response.instance_of? FatalErrorResponse
74
+ # Do nothing
75
+ else
76
+ remote_broker.respond_to(request, response)
77
+ end
78
+ end
79
+
80
+ def prepare_for_next_request(remote_broker, response)
81
+ if response.instance_of? FatalErrorResponse
82
+ remote_broker.close
83
+ else
84
+ # Do nothing
85
+ end
71
86
  end
72
-
73
87
  end
74
88
  end
75
89
  end
@@ -1,5 +1,4 @@
1
1
  require 'tdl/queue/queue_based_implementation_runner'
2
- require 'tdl/queue/actions/client_actions'
3
2
 
4
3
  module TDL
5
4
 
@@ -14,11 +13,11 @@ module TDL
14
13
  self
15
14
  end
16
15
 
17
- def with_solution_for(method_name, user_implementation, action = ClientActions.publish)
16
+ def with_solution_for(method_name, user_implementation)
18
17
  @deploy_processing_rules
19
18
  .on(method_name)
20
19
  .call(user_implementation)
21
- .then(action)
20
+ .build()
22
21
  self
23
22
  end
24
23
 
@@ -31,7 +30,7 @@ module TDL
31
30
  deploy_processing_rules
32
31
  .on('display_description')
33
32
  .call(-> (*params) {'OK'})
34
- .then(ClientActions.publish)
33
+ .build()
35
34
  deploy_processing_rules
36
35
  end
37
36
 
@@ -4,11 +4,10 @@ require 'tdl/queue/serialization/json_rpc_serialization_provider'
4
4
 
5
5
  module TDL
6
6
  class RemoteBroker
7
- def initialize(hostname, port, unique_id, request_timeout_millis)
7
+ def initialize(hostname, port, request_queue_name, response_queue_name, request_timeout_millis)
8
8
  @stomp_client = Stomp::Client.new('', '', hostname, port)
9
- @unique_id = unique_id
10
- @request_queue = "/queue/#{@unique_id}.req"
11
- @response_queue = "/queue/#{@unique_id}.resp"
9
+ @request_queue = "/queue/#{request_queue_name}"
10
+ @response_queue = "/queue/#{response_queue_name}"
12
11
  @serialization_provider = JSONRPCSerializationProvider.new
13
12
  @timer = ThreadTimer.new(request_timeout_millis, lambda = ->() { close unless closed? })
14
13
  @timer.start
@@ -1,25 +1,20 @@
1
- require 'tdl/queue/actions/client_actions'
2
-
3
- include TDL::ClientActions
4
-
5
1
  class RunnerAction
6
- attr_reader :short_name, :name, :client_action
2
+ attr_reader :short_name, :name
7
3
 
8
- def initialize(short_name, name, client_action)
4
+ def initialize(short_name, name)
9
5
  @short_name = short_name
10
6
  @name = name
11
- @client_action = client_action
12
7
  end
13
8
 
14
9
  end
15
10
 
16
11
  module RunnerActions
17
12
  def get_new_round_description
18
- RunnerAction.new('new', 'get_new_round_description', TDL::ClientActions.stop)
13
+ RunnerAction.new('new', 'get_new_round_description')
19
14
  end
20
15
 
21
16
  def deploy_to_production
22
- RunnerAction.new('deploy', 'deploy_to_production', TDL::ClientActions.publish)
17
+ RunnerAction.new('deploy', 'deploy_to_production')
23
18
  end
24
19
 
25
20
  def all
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+ set -u
5
+ set -o pipefail
6
+
7
+ startWiremocks() {
8
+ echo "~~~~~~~~~~ Starting Wiremocks on ports 41375 and 8222 ~~~~~~~~~"
9
+ python wiremock/wiremock-wrapper.py start 41375
10
+ python wiremock/wiremock-wrapper.py start 8222
11
+ }
12
+
13
+ startBroker() {
14
+ echo "~~~~~~~~~~ Starting Broker ~~~~~~~~~"
15
+ python broker/activemq-wrapper.py start
16
+ }
17
+
18
+ startWiremocks
19
+ startBroker
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+ set -u
5
+ set -o pipefail
6
+
7
+ stopProcessAtPort() {
8
+ PORT=$1
9
+ PID=$(netstat -tulpn | grep :${PORT} | awk '{print $7}' | tr -d "/java" || true)
10
+ if [[ -z "${PID}" ]]; then
11
+ echo "~~~~~~~~~~ Process on port ${PORT} stopped ~~~~~~~~~"
12
+ else
13
+ kill -9 ${PID}
14
+ echo "~~~~~~~~~~ Process on port ${PORT} killed ~~~~~~~~~"
15
+ fi
16
+ }
17
+
18
+ stopWiremocks() {
19
+ echo "~~~~~~~~~~ Stopping Wiremocks listening on ports 41375 and 8222 ~~~~~~~~~"
20
+ python wiremock/wiremock-wrapper.py stop || true
21
+
22
+ stopProcessAtPort 41375
23
+ stopProcessAtPort 8222
24
+ }
25
+
26
+ stopBroker() {
27
+ echo "~~~~~~~~~~ Stoping Broker ~~~~~~~~~"
28
+ python broker/activemq-wrapper.py stop || true
29
+ }
30
+
31
+ stopWiremocks
32
+ stopBroker
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.22.1
4
+ version: 0.25.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: 2018-08-03 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stomp
@@ -217,10 +217,6 @@ files:
217
217
  - lib/tdl/queue/abstractions/request.rb
218
218
  - lib/tdl/queue/abstractions/response/fatal_error_response.rb
219
219
  - lib/tdl/queue/abstractions/response/valid_response.rb
220
- - lib/tdl/queue/actions/client_actions.rb
221
- - lib/tdl/queue/actions/publish_action.rb
222
- - lib/tdl/queue/actions/publish_and_stop_action.rb
223
- - lib/tdl/queue/actions/stop_action.rb
224
220
  - lib/tdl/queue/implementation_runner_config.rb
225
221
  - lib/tdl/queue/processing_rules.rb
226
222
  - lib/tdl/queue/queue_based_implementation_runner.rb
@@ -237,13 +233,15 @@ files:
237
233
  - lib/tdl/thread_timer.rb
238
234
  - lib/tdl/util.rb
239
235
  - release.sh
236
+ - startExternalDependencies.sh
237
+ - stopExternalDependencies.sh
240
238
  - tdl-client-ruby.gemspec
241
239
  - tdl-client-ruby.iml
242
240
  homepage: https://github.com/julianghionoiu/tdl-client-ruby
243
241
  licenses:
244
242
  - GPL-3.0
245
243
  metadata:
246
- previous_version: 0.21.1
244
+ previous_version: 0.22.1
247
245
  post_install_message:
248
246
  rdoc_options: []
249
247
  require_paths:
@@ -1,20 +0,0 @@
1
- require 'tdl/queue/actions/publish_action'
2
- require 'tdl/queue/actions/stop_action'
3
- require 'tdl/queue/actions/publish_and_stop_action'
4
-
5
- module TDL
6
- module ClientActions
7
-
8
- def publish
9
- PublishAction.new
10
- end
11
-
12
- def stop
13
- StopAction.new
14
- end
15
-
16
- def publish_and_stop
17
- PublishAndStopAction.new
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- module TDL
2
- class PublishAction
3
-
4
- def audit_text
5
- ''
6
- end
7
-
8
- def after_response(remote_broker, request, response)
9
- remote_broker.respond_to(request, response)
10
- end
11
-
12
- def prepare_for_next_request(remote_broker)
13
- # DO nothing
14
- end
15
-
16
- end
17
- end
@@ -1,16 +0,0 @@
1
- module TDL
2
- class PublishAndStopAction
3
-
4
- def audit_text
5
- ''
6
- end
7
-
8
- def after_response(remote_broker, request, response)
9
- remote_broker.respond_to(request, response)
10
- end
11
-
12
- def prepare_for_next_request(remote_broker)
13
- remote_broker.close
14
- end
15
- end
16
- end
@@ -1,17 +0,0 @@
1
- module TDL
2
- class StopAction
3
-
4
- def audit_text
5
- '(NOT PUBLISHED)'
6
- end
7
-
8
- def after_response(remote_broker, request, response)
9
- # do nothing
10
- end
11
-
12
- def prepare_for_next_request(remote_broker)
13
- remote_broker.close
14
- end
15
-
16
- end
17
- end