rservicebus2 0.2.7 → 0.2.8

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: e5cab110a6dd40b7b80824e669ac85709bbec790bc948d5bdcb954a1b29184a5
4
- data.tar.gz: 1bc1c569d5af1d01e79c69c0aef99781498bdac5aac13671fd4cd47a286aa2b1
3
+ metadata.gz: 5f94672750deba44e6495d728b6c45bbf0aba95efe35d18b6877359e27173da4
4
+ data.tar.gz: 27e94561da7ab338ee3ff5ac99f850f872900f2559bb56ce3dffd604c452173a
5
5
  SHA512:
6
- metadata.gz: 64d2065fbd9b061cf17eca6f9c8eea5e8aa4663a9e68a27463417d511496d9e329d2d2d227bd7dc0b677f39e1a0f62b56292394f5b22217517f80f097698b2dc
7
- data.tar.gz: 5637363459b8c27057d5d2cba9bbd99f558a3a25fbf4f0d0e2971d4e249e8ab58001f123fee08e82c4ee116c38d849ae9ecafd5452c4416f319277e2c91bbabb
6
+ metadata.gz: ac819c545740eb82ecf1ae2b95286f837ae1189ba3eded36ddcc98680ce4b7dcc84b975d9c75ab48e62f99cef32a83d98fdf2ad195bab0012f2804392abb3289
7
+ data.tar.gz: c10528a4a06fc27f9e2c5541dd4d500a1ae2120cc0f89a4a66c165a09c6fb5eae014c04ab74735c29069c6b6f8ebfaf089c7f2f63d80cdc02fb7d4acf3f7cc7b
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
 
3
5
  module RServiceBus2
@@ -8,7 +10,7 @@ module RServiceBus2
8
10
 
9
11
  # The method which actually connects to the resource.
10
12
  def connect(_uri)
11
- fail 'Method, connect, needs to be implemented for resource'
13
+ raise 'Method, connect, needs to be implemented for resource'
12
14
  end
13
15
 
14
16
  def _connect
@@ -44,22 +46,19 @@ module RServiceBus2
44
46
  rescue StandardError => e
45
47
  puts '** AppResource. An error was raised while closing connection
46
48
  to, ' + @uri
47
- puts 'Message: ' + e.message
49
+ puts "Message: #{e.message}"
48
50
  puts e.backtrace
49
51
  end
50
52
  _connect
51
53
  end
52
54
 
53
55
  # Transaction Semantics
54
- def begin
55
- end
56
+ def begin; end
56
57
 
57
58
  # Transaction Semantics
58
- def commit
59
- end
59
+ def commit; end
60
60
 
61
61
  # Transaction Semantics
62
- def rollback
63
- end
62
+ def rollback; end
64
63
  end
65
64
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RServiceBus2
2
4
  class MessageArrivedWhileCricuitBroken < StandardError
3
5
  end
@@ -42,7 +44,7 @@ module RServiceBus2
42
44
  message_arrived
43
45
 
44
46
  ## logFirstFailure
45
- if @number_of_failures == 0
47
+ if @number_of_failures.zero?
46
48
  @number_of_failures = 1
47
49
  @time_of_first_failure = Time.now
48
50
  @time_to_break = @time_of_first_failure + @seconds_to_break
@@ -68,7 +70,7 @@ module RServiceBus2
68
70
  def message_arrived
69
71
  reset if !@time_to_break.nil? && Time.now > @time_to_break
70
72
 
71
- fail MessageArrivedWhileCricuitBroken if @broken == true
73
+ raise MessageArrivedWhileCricuitBroken if @broken == true
72
74
  end
73
75
 
74
76
  def break_circuit
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RServiceBus2
2
4
  # Marshals configuration information for an rservicebus host
3
5
  class Config
@@ -19,7 +21,7 @@ module RServiceBus2
19
21
  end
20
22
 
21
23
  def get_value(name, default = nil)
22
- value = (ENV[name].nil? || ENV[name] == '') ? default : ENV[name]
24
+ value = ENV[name].nil? || ENV[name] == '' ? default : ENV[name]
23
25
  log "Env value: #{name}: #{value}"
24
26
  value
25
27
  end
@@ -131,21 +133,19 @@ module RServiceBus2
131
133
  # Note. trailing slashs will be stripped
132
134
  # Expected format: <path 1>;<path 2>
133
135
  def load_working_dir_list
134
- puts "Config.load_working_dir_list.1"
135
- puts "Config.load_working_dir_list.2 #{@contract_list}"
136
136
  path_list = get_value('WORKING_DIR', './')
137
137
  return self if path_list.nil?
138
138
 
139
139
  path_list.split(';').each do |path|
140
140
  path = path.strip.chomp('/')
141
- unless Dir.exist?("#{path}")
141
+ unless Dir.exist?(path.to_s)
142
142
  puts 'Error while processing working directory list'
143
143
  puts "*** path, #{path}, does not exist"
144
144
  abort
145
145
  end
146
146
  @handler_path_list << "#{path}/messagehandler" if Dir.exist?("#{path}/messagehandler")
147
147
  @saga_path_list << "#{path}/saga" if Dir.exist?("#{path}/saga")
148
- @contract_list << "#{path}/contract.rb" if File.exist?( "#{path}/contract.rb" )
148
+ @contract_list << "#{path}/contract.rb" if File.exist?("#{path}/contract.rb")
149
149
  @lib_list << "#{path}/lib" if File.exist?("#{path}/lib")
150
150
  end
151
151
  self
@@ -154,14 +154,11 @@ module RServiceBus2
154
154
 
155
155
  # Class
156
156
  class ConfigFromEnv < Config
157
- def initialize
158
- end
159
157
  end
160
158
 
161
159
  # Class
162
160
  class ConfigFromSetter < Config
163
- attr_writer :appName, :messageEndpointMappings, :handler_path_list, :errorQueueName, :maxRetries, :forward_received_messages_to, :beanstalkHost
164
- def initialize
165
- end
161
+ attr_writer :app_name, :message_endpoint_mappings, :handler_path_list, :error_queue_name, \
162
+ :max_retries, :forward_received_messages_to, :beanstalk_host
166
163
  end
167
164
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'parse-cron'
2
4
 
3
5
  module RServiceBus2
@@ -27,7 +29,8 @@ module RServiceBus2
27
29
  @msg_names.each do |n|
28
30
  list << n if Globber.new(name) =~ n
29
31
  end
30
- fail NoMatchingMsgForCron, name if list.length == 0
32
+ raise NoMatchingMsgForCron, name if list.empty?
33
+
31
34
  list
32
35
  end
33
36
 
@@ -44,6 +47,7 @@ module RServiceBus2
44
47
  end
45
48
  end
46
49
 
50
+ # rubocop:disable Metrics/MethodLength
47
51
  def initialize(host, msg_names = [])
48
52
  @bus = host
49
53
  @msg_names = msg_names
@@ -61,6 +65,7 @@ module RServiceBus2
61
65
  end
62
66
  end
63
67
  end
68
+ # rubocop:enable Metrics/MethodLength
64
69
 
65
70
  def run
66
71
  now = Time.now
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RServiceBus2
2
4
  # Marshals data for message end points
3
5
  # Expected format: <msg mame 1>:<end point 1>;<msg mame 2>:<end point 2>
@@ -6,16 +8,18 @@ module RServiceBus2
6
8
  RServiceBus2.get_value(name)
7
9
  end
8
10
 
9
- def log(string, _ver = false)
11
+ def log(string, _ver: false)
10
12
  RServiceBus2.log(string)
11
13
  end
12
14
 
15
+ # rubocop:disable Metrics/AbcSize
16
+ # rubocop:disable Metrics/MethodLength
13
17
  def configure_mapping(mapping)
14
18
  match = mapping.match(/(.+):(.+)/)
15
19
  if match.nil?
16
- log 'Mapping string provided is invalid'
17
- log "The entire mapping string is: #{mapping}"
18
- log "*** Could not find ':' in mapping entry, #{line}"
20
+ log 'Mapping string provided is invalid\n' \
21
+ "The entire mapping string is: #{mapping}\n" \
22
+ "*** Could not find ':' in mapping entry, #{line}\n"
19
23
  exit
20
24
  end
21
25
 
@@ -23,16 +27,19 @@ module RServiceBus2
23
27
  @endpoints[match[1]] = match[2]
24
28
 
25
29
  @queue_name_list.each do |q|
26
- if q != match[2] && q.downcase == match[2].downcase
27
- log('*** Two queues specified with only case sensitive difference.')
28
- log("*** #{q} != #{match[2]}")
29
- log('*** If you meant these queues to be the same, please match case
30
- and restart the bus.')
31
- end
30
+ next unless q != match[2] && q.downcase == match[2].downcase
31
+
32
+ log('*** Two queues specified with only case sensitive difference.')
33
+ log("*** #{q} != #{match[2]}")
34
+ log('*** If you meant these queues to be the same, please match case
35
+ and restart the bus.')
32
36
  end
33
37
  @queue_name_list << match[2]
34
38
  end
39
+ # rubocop:enable Metrics/AbcSize
40
+ # rubocop:enable Metrics/MethodLength
35
41
 
42
+ # rubocop:disable Metrics/MethodLength
36
43
  def configure(local_queue_name = nil)
37
44
  log('EndpointMapping.Configure')
38
45
 
@@ -40,9 +47,9 @@ module RServiceBus2
40
47
  @queue_name_list << local_queue_name unless local_queue_name.nil?
41
48
 
42
49
  unless get_value('MESSAGE_ENDPOINT_MAPPING').nil?
43
- log('*** MESSAGE_ENDPOINT_MAPPING environment variable was detected')
44
- log("*** You may have intended MESSAGE_ENDPOINT_MAPPINGS, note the 'S'
45
- on the end")
50
+ log '*** MESSAGE_ENDPOINT_MAPPING environment variable was detected\n' \
51
+ "*** You may have intended MESSAGE_ENDPOINT_MAPPINGS, note the 'S'
52
+ on the end"
46
53
  end
47
54
 
48
55
  mappings = get_value('MESSAGE_ENDPOINT_MAPPINGS')
@@ -54,6 +61,7 @@ module RServiceBus2
54
61
 
55
62
  self
56
63
  end
64
+ # rubocop:enable Metrics/MethodLength
57
65
 
58
66
  def initialize
59
67
  @endpoints = {}
@@ -65,7 +73,7 @@ module RServiceBus2
65
73
  nil
66
74
  end
67
75
 
68
- def get_subscription_endpoints
76
+ def subscription_endpoints
69
77
  @endpoints.keys.select { |el| el.end_with?('Event') }
70
78
  end
71
79
  end
@@ -1,5 +1,6 @@
1
- module RServiceBus2
1
+ # frozen_string_literal: true
2
2
 
3
+ module RServiceBus2
3
4
  # Error Message
4
5
  class ErrorMessage
5
6
  attr_reader :occurredat, :source_queue, :error_msg
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RServiceBus2
2
4
  # Given a directory, this class is responsible for finding
3
5
  # msgnames,
4
6
  # handlernames, and
5
7
  # loading handlers
6
8
  class HandlerLoader
7
- attr_reader :handlerList
9
+ # attr_reader :handlerList - 8 May 2021
8
10
 
9
11
  # Constructor
10
12
  #
@@ -22,12 +24,11 @@ module RServiceBus2
22
24
  # Cleans the given path to ensure it can be used for as a parameter for the require statement.
23
25
  # @param [String] file_path the path to be cleaned
24
26
  def get_require_path(file_path)
25
- file_path = './' + file_path unless file_path.start_with?('/')
27
+ file_path = "./#{file_path}" unless file_path.start_with?('/')
26
28
 
27
29
  return file_path.sub('.rb', '') if File.exist?(file_path)
28
30
 
29
- abort('Filepath, ' + file_path + ", given for messagehandler require
30
- doesn't exist")
31
+ abort("Filepath, #{file_path}, given for messagehandler require doesn't exist")
31
32
  end
32
33
 
33
34
  # Instantiate the handler named in handlerName from the file name in
@@ -38,6 +39,7 @@ module RServiceBus2
38
39
  # @param [String] handler_name name of the handler to instantiate
39
40
  # @param [String] file_path the path to the file to be loaded
40
41
  # @return [RServiceBus2::Handler] the loader
42
+ # rubocop:disable Metrics/MethodLength
41
43
  def load_handler_from_file(handler_name, file_path)
42
44
  require_path = get_require_path(file_path)
43
45
 
@@ -45,22 +47,22 @@ module RServiceBus2
45
47
  begin
46
48
  handler = Object.const_get(handler_name).new
47
49
  rescue StandardError => e
48
- puts 'Expected class name: ' + handler_name + ', not found after
49
- require: ' + require_path
50
- puts '**** Check in ' + file_path + ' that the class is named : ' +
51
- handler_name
52
- puts '( In case its not that )'
50
+ puts "Expected class name: #{handler_name}, not found after require: #{require_path}\n" \
51
+ "**** Check in #{file_path} that the class is named: #{handler_name}\n" \
52
+ '( In case its not that )'
53
53
  raise e
54
54
  end
55
55
 
56
56
  handler
57
57
  end
58
+ # rubocop:enable Metrics/MethodLength
58
59
 
59
60
  # Wrapper function
60
61
  #
61
62
  # @param [String] file_path
62
63
  # @param [String] handler_name
63
64
  # @returns [RServiceBus2::Handler] handler
65
+ # rubocop:disable Metrics/MethodLength
64
66
  def load_handler(msg_name, file_path, handler_name)
65
67
  if @list_of_loaded_paths.key?(file_path)
66
68
  RServiceBus2.log "Not reloading, #{file_path}"
@@ -68,29 +70,30 @@ module RServiceBus2
68
70
  end
69
71
 
70
72
  begin
71
- RServiceBus2.rlog 'file_path: ' + file_path
72
- RServiceBus2.rlog 'handler_name: ' + handler_name
73
+ RServiceBus2.rlog "file_path: #{file_path}"
74
+ RServiceBus2.rlog "handler_name: #{handler_name}"
73
75
 
74
76
  handler = load_handler_from_file(handler_name, file_path)
75
- RServiceBus2.log 'Loaded Handler: ' + handler_name
77
+ RServiceBus2.log "Loaded Handler: #{handler_name}"
76
78
 
77
79
  @handler_manager.add_handler(msg_name, handler)
78
80
 
79
81
  @list_of_loaded_paths[file_path] = 1
80
82
  rescue StandardError => e
81
- puts 'Exception loading handler from file: ' + file_path
83
+ puts "Exception loading handler from file: #{file_path}"
82
84
  puts e.message
83
85
  puts e.backtrace[0]
84
86
  abort
85
87
  end
86
88
  end
89
+ # rubocop:enable Metrics/MethodLength
87
90
 
88
91
  # This method is overloaded for unit tests
89
92
  #
90
93
  # @param [String] path directory to check
91
94
  # @return [Array] a list of paths to files found in the given path
92
95
  def get_list_of_files_for_dir(path)
93
- list = Dir[path + '/*']
96
+ list = Dir["#{path}/*"]
94
97
  RServiceBus2.rlog "HandlerLoader.getListOfFilesForDir. path: #{path},
95
98
  list: #{list}"
96
99
  list
@@ -105,14 +108,14 @@ module RServiceBus2
105
108
  def load_handlers_from_second_level_path(msg_name, base_dir)
106
109
  get_list_of_files_for_dir(base_dir).each do |file_path|
107
110
  next if file_path.end_with?('.')
111
+ next unless !File.directory?(file_path) && File.extname(file_path) == '.rb'
108
112
 
109
- ext_name = File.extname(file_path)
110
- if !File.directory?(file_path) && ext_name == '.rb'
111
- file_name = File.basename(file_path).sub('.rb', '')
112
- handler_name = "message_handler_#{msg_name}_#{file_name}".gsub(/(?<=_|^)(\w)/){$1.upcase}.gsub(/(?:_)(\w)/,'\1') # Classify
113
+ file_name = File.basename(file_path).sub('.rb', '')
114
+ # Classify
115
+ handler_name = "message_handler_#{msg_name}_#{file_name}"
116
+ .gsub(/(?<=_|^)(\w)/) { Regexp.last_match(1).upcase }.gsub(/(?:_)(\w)/, '\1')
113
117
 
114
- load_handler(msg_name, file_path, handler_name)
115
- end
118
+ load_handler(msg_name, file_path, handler_name)
116
119
  end
117
120
 
118
121
  self
@@ -130,22 +133,26 @@ module RServiceBus2
130
133
  # Load top level handlers from the given directory
131
134
  #
132
135
  # @param [String] baseDir directory to check - should not have trailing slash
136
+ # rubocop:disable Metrics/MethodLength
133
137
  def load_handlers_from_top_level_path(base_dir)
134
138
  RServiceBus2.rlog "HandlerLoader.loadHandlersFromTopLevelPath. baseDir: #{base_dir}"
135
139
  get_list_of_files_for_dir(base_dir).each do |file_path|
136
- unless file_path.end_with?('.')
137
- msg_name = get_msg_name(file_path)
138
- if File.directory?(file_path)
139
- load_handlers_from_second_level_path(msg_name, file_path)
140
- else
141
- handler_name = "message_handler_#{msg_name}".gsub(/(?<=_|^)(\w)/){$1.upcase}.gsub(/(?:_)(\w)/,'\1') # Classify
142
- load_handler(msg_name, file_path, handler_name)
143
- end
140
+ next if file_path.end_with?('.')
141
+
142
+ msg_name = get_msg_name(file_path)
143
+ if File.directory?(file_path)
144
+ load_handlers_from_second_level_path(msg_name, file_path)
145
+ else
146
+ # Classify
147
+ handler_name = "message_handler_#{msg_name}"
148
+ .gsub(/(?<=_|^)(\w)/) { Regexp.last_match(1).upcase }.gsub(/(?:_)(\w)/, '\1')
149
+ load_handler(msg_name, file_path, handler_name)
144
150
  end
145
151
  end
146
152
 
147
153
  self
148
154
  end
155
+ # rubocop:enable Metrics/MethodLength
149
156
 
150
157
  # Entry point for loading handlers
151
158
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RServiceBus2
2
4
  # Given a directory, this class is responsible for finding
3
5
  # msgnames,
@@ -20,10 +22,10 @@ module RServiceBus2
20
22
  # setBusAttributeIfRequested
21
23
  #
22
24
  # @param [RServiceBus2::Handler] handler
23
- def set_bus_attribute_if_requested(handler)
25
+ def conditionally_set_bus_attribute(handler)
24
26
  if defined?(handler.bus)
25
27
  handler.bus = @host
26
- RServiceBus2.log 'Bus attribute set for: ' + handler.class.name
28
+ RServiceBus2.log "Bus attribute set for: #{handler.class.name}"
27
29
  end
28
30
 
29
31
  self
@@ -32,10 +34,10 @@ module RServiceBus2
32
34
  # setStateAttributeIfRequested
33
35
  #
34
36
  # @param [RServiceBus2::Handler] handler
35
- def set_state_attribute_if_requested(handler)
37
+ def conditionally_set_state_attribute(handler)
36
38
  if defined?(handler.state)
37
39
  handler.state = @state_manager.get(handler)
38
- RServiceBus2.log 'Bus attribute set for: ' + handler.class.name
40
+ RServiceBus2.log "Bus attribute set for: #{handler.class.name}"
39
41
  end
40
42
 
41
43
  self
@@ -50,29 +52,29 @@ module RServiceBus2
50
52
  self
51
53
  end
52
54
 
55
+ # rubocop:disable Metrics/AbcSize
53
56
  def interrogate_handler_for_app_resources(handler)
54
- RServiceBus2.rlog "Checking app resources for: #{handler.class.name}"
55
- RServiceBus2.rlog "If your attribute is not getting set, check that it is in the 'attr_accessor' list"
57
+ RServiceBus2.rlog "Checking app resources for: #{handler.class.name}\n" \
58
+ "If your attribute is not getting set, check that it is in the 'attr_accessor' list"
56
59
 
57
60
  @resource_list_by_handler_name[handler.class.name] = []
58
- @resource_manager.get_all.each do |k, v|
61
+ @resource_manager.all.each do |k, _v|
59
62
  next unless handler.class.method_defined?(k)
60
63
 
61
64
  @resource_list_by_handler_name[handler.class.name] << k
62
- RServiceBus2.log "Resource attribute, #{k}, found for: " +
63
- handler.class.name
65
+ RServiceBus2.log "Resource attribute, #{k}, found for: #{handler.class.name}"
64
66
  end
65
-
66
- self
67
67
  end
68
+ # rubocop:enable Metrics/AbcSize
68
69
 
69
70
  def add_handler(lc_msg_name, handler)
70
- msg_name = lc_msg_name.gsub(/(?<=_|^)(\w)/){$1.upcase}.gsub(/(?:_)(\w)/,'\1') # Turn snake_case string to CamelCase
71
+ # Turn snake_case string to CamelCase
72
+ msg_name = lc_msg_name.gsub(/(?<=_|^)(\w)/) { Regexp.last_match(1).upcase }.gsub(/(?:_)(\w)/, '\1')
71
73
  @handler_list[msg_name] = [] if @handler_list[msg_name].nil?
72
- return unless @handler_list[msg_name].index{ |x| x.class.name == handler.class.name }.nil?
74
+ return unless @handler_list[msg_name].index { |x| x.instance_of(handler) }.nil?
73
75
 
74
76
  @handler_list[msg_name] << handler
75
- set_bus_attribute_if_requested(handler)
77
+ conditionally_set_bus_attribute(handler)
76
78
  check_if_state_attribute_requested(handler)
77
79
  interrogate_handler_for_app_resources(handler)
78
80
  end
@@ -86,28 +88,32 @@ module RServiceBus2
86
88
 
87
89
  list = []
88
90
  @handler_list[msg_name].each do |handler|
89
- list = list + @resource_list_by_handler_name[handler.class.name] unless @resource_list_by_handler_name[handler.class.name].nil?
91
+ unless @resource_list_by_handler_name[handler.class.name].nil?
92
+ list += @resource_list_by_handler_name[handler.class.name]
93
+ end
90
94
  end
91
95
  list.uniq!
92
96
  end
93
97
 
94
- def set_resources_for_handlers_needed_to_process_msg(msg_name)
98
+ # rubocop:disable Metrics/AbcSize
99
+ def conditionally_set_resources_for_handlers(msg_name)
95
100
  @handler_list[msg_name].each do |handler|
96
- set_state_attribute_if_requested(handler)
97
-
101
+ conditionally_set_state_attribute(handler)
98
102
  next if @resource_list_by_handler_name[handler.class.name].nil?
103
+
99
104
  @resource_list_by_handler_name[handler.class.name].each do |k|
100
105
  handler.instance_variable_set("@#{k}", @resource_manager.get(k).get_resource)
101
- RServiceBus2.rlog "App resource attribute, #{k}, set for: " + handler.class.name
106
+ RServiceBus2.rlog "App resource attribute, #{k}, set for: #{handler.class.name}"
102
107
  end
103
108
  end
104
109
  end
110
+ # rubocop:enable Metrics/AbcSize
105
111
 
106
112
  def get_handler_list_for_msg(msg_name)
107
113
  return [] if @handler_list[msg_name].nil?
108
114
 
109
- list = get_list_of_resources_needed_to_process_msg(msg_name)
110
- set_resources_for_handlers_needed_to_process_msg(msg_name)
115
+ # list = get_list_of_resources_needed_to_process_msg(msg_name)
116
+ conditionally_set_resources_for_handlers(msg_name)
111
117
 
112
118
  @handler_list[msg_name]
113
119
  end
@@ -116,16 +122,16 @@ module RServiceBus2
116
122
  @handler_list.key?(msg_name)
117
123
  end
118
124
 
119
- def get_stats
125
+ def stats
120
126
  list = []
121
- @handler_list.each do |k, v|
127
+ @handler_list.each do |_k, v|
122
128
  list << v.inspect
123
129
  end
124
130
 
125
131
  list
126
132
  end
127
133
 
128
- def get_list_of_msg_names
134
+ def msg_names
129
135
  @handler_list.keys
130
136
  end
131
137
  end
@@ -74,7 +74,7 @@ module RServiceBus2
74
74
  def send_subscriptions
75
75
  log 'Send Subscriptions'
76
76
 
77
- @endpoint_mapping.get_subscription_endpoints.each do |event_name|
77
+ @endpoint_mapping.subscription_endpoints.each do |event_name|
78
78
  subscribe(event_name)
79
79
  end
80
80
 
@@ -109,7 +109,7 @@ module RServiceBus2
109
109
 
110
110
  # Thin veneer for Configuring Cron
111
111
  def configure_cron_manager
112
- @cron_manager = CronManager.new(self, @handler_manager.get_list_of_msg_names)
112
+ @cron_manager = CronManager.new(self, @handler_manager.msg_names)
113
113
  self
114
114
  end
115
115
 
@@ -23,7 +23,7 @@ module RServiceBus2
23
23
  RServiceBus2.rlog "Checking app resources for: #{monitor.class.name}"
24
24
  RServiceBus2.rlog "If your attribute is not getting set, check that it is
25
25
  in the 'attr_accessor' list"
26
- @resource_manager.get_all.each do |k, v|
26
+ @resource_manager.all.each do |k, v|
27
27
  next unless monitor.class.method_defined?(k)
28
28
 
29
29
  monitor.instance_variable_set("@#{k}", v.get_resource)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RServiceBus2
2
4
  # Coordinate Transactions across resources, handlers, and Sagas
3
5
  class ResourceManager
@@ -13,7 +15,7 @@ module RServiceBus2
13
15
  @app_resources[name] = res
14
16
  end
15
17
 
16
- def get_all
18
+ def all
17
19
  @app_resources
18
20
  end
19
21
 
@@ -37,9 +39,8 @@ module RServiceBus2
37
39
  def commit(msg_name)
38
40
  @state_manager.commit
39
41
  @saga_storage.commit
40
- RServiceBus2.rlog "HandlerManager.commitResourcesUsedToProcessMsg,
41
- #{msg_name}"
42
- @current_resources.each do |k, v|
42
+ RServiceBus2.rlog "HandlerManager.commitResourcesUsedToProcessMsg, #{msg_name}"
43
+ @current_resources.each do |_k, v|
43
44
  RServiceBus2.rlog "Commit resource, #{v.class.name}"
44
45
  v.commit
45
46
  v.finished
@@ -48,21 +49,15 @@ module RServiceBus2
48
49
 
49
50
  def rollback(msg_name)
50
51
  @saga_storage.rollback
51
- RServiceBus2.rlog "HandlerManager.rollbackResourcesUsedToProcessMsg,
52
- #{msg_name}"
53
- @current_resources.each do |k, v|
54
- begin
55
- RServiceBus2.rlog "Rollback resource, #{v.class.name}"
56
- v.rollback
57
- v.finished
58
- rescue StandardError => e1
59
- puts "Caught nested exception rolling back, #{v.class.name}, for msg,
60
- #{msg_name}"
61
- puts '****'
62
- puts e1.message
63
- puts e1.backtrace
64
- puts '****'
65
- end
52
+ RServiceBus2.rlog "HandlerManager.rollbackResourcesUsedToProcessMsg, #{msg_name}"
53
+ @current_resources.each do |_k, v|
54
+ RServiceBus2.rlog "Rollback resource, #{v.class.name}"
55
+ v.rollback
56
+ v.finished
57
+ rescue StandardError => e
58
+ puts "Caught nested exception rolling back, #{v.class.name}, for msg,
59
+ #{msg_name}"
60
+ puts "****\n#{e.message}\n#{e.backtrace}\n'****"
66
61
  end
67
62
  end
68
63
  end
@@ -44,7 +44,7 @@ module RServiceBus2
44
44
  is in the 'attr_accessor' list"
45
45
 
46
46
  @resource_list_by_saga_name[saga.class.name] = []
47
- @resource_manager.get_all.each do |k, v|
47
+ @resource_manager.all.each do |k, v|
48
48
  if saga.class.method_defined?(k)
49
49
  @resource_list_by_saga_name[saga.class.name] << k
50
50
  RServiceBus2.log "Resource attribute, #{k}, found for: " +
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rservicebus2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Irvine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-01 00:00:00.000000000 Z
11
+ date: 2021-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beanstalk-client