rservicebus2 0.2.9 → 0.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rservicebus2.rb +6 -5
- data/lib/rservicebus2/agent.rb +2 -2
- data/lib/rservicebus2/appresource/awss3.rb +3 -3
- data/lib/rservicebus2/appresource/awssqs.rb +2 -0
- data/lib/rservicebus2/appresource/dir.rb +3 -0
- data/lib/rservicebus2/appresource/file.rb +2 -0
- data/lib/rservicebus2/appresource/fluiddb.rb +3 -0
- data/lib/rservicebus2/appresource/fluiddb2.rb +3 -1
- data/lib/rservicebus2/config.rb +38 -29
- data/lib/rservicebus2/endpointmapping.rb +2 -4
- data/lib/rservicebus2/errormessage.rb +1 -1
- data/lib/rservicebus2/handler_manager.rb +1 -1
- data/lib/rservicebus2/helper_functions.rb +13 -12
- data/lib/rservicebus2/host.rb +5 -5
- data/lib/rservicebus2/message.rb +11 -19
- data/lib/rservicebus2/message/statisticoutput.rb +2 -0
- data/lib/rservicebus2/message/subscription.rb +2 -0
- data/lib/rservicebus2/message/verboseoutput.rb +2 -0
- data/lib/rservicebus2/monitor.rb +7 -7
- data/lib/rservicebus2/monitor/awss3.rb +3 -1
- data/lib/rservicebus2/monitor/awssqs.rb +9 -7
- data/lib/rservicebus2/monitor/beanstalk.rb +53 -0
- data/lib/rservicebus2/monitor/dir.rb +25 -23
- data/lib/rservicebus2/monitor/dirnotifier.rb +4 -1
- data/lib/rservicebus2/monitor/message.rb +2 -0
- data/lib/rservicebus2/monitor/xmldir.rb +2 -0
- data/lib/rservicebus2/monitor_configure.rb +49 -36
- data/lib/rservicebus2/mq.rb +27 -30
- data/lib/rservicebus2/mq/beanstalk.rb +5 -1
- data/lib/rservicebus2/saga/data.rb +1 -1
- data/lib/rservicebus2/saga_loader.rb +27 -24
- data/lib/rservicebus2/saga_storage.rb +5 -4
- data/lib/rservicebus2/sendat_manager.rb +5 -3
- data/lib/rservicebus2/sendat_storage.rb +5 -3
- data/lib/rservicebus2/sendat_storage/file.rb +6 -2
- data/lib/rservicebus2/sendat_storage/inmemory.rb +2 -0
- data/lib/rservicebus2/state_manager.rb +5 -4
- data/lib/rservicebus2/state_storage.rb +7 -6
- data/lib/rservicebus2/statistic_manager.rb +7 -3
- data/lib/rservicebus2/subscription_manager.rb +7 -5
- data/lib/rservicebus2/subscription_storage.rb +6 -5
- data/lib/rservicebus2/subscription_storage/file.rb +5 -18
- data/lib/rservicebus2/subscription_storage_configure.rb +2 -0
- data/lib/rservicebus2/transporter.rb +63 -52
- metadata +3 -3
- data/lib/rservicebus2/stats.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb17f3e3c5855d25725fd906122c5880299c33ef25a585d445b1ca63eb3b0a79
|
4
|
+
data.tar.gz: b950f8c099a79b02837dc6c1382ae4f36eb20d6b35f9c7e06f3351ac11804803
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebb2ef88679f5827b905fc50f604c41dacbaaecbf5878181c0ce46801d9cb24d8df060ef4c39ef37f6bfd130a7dc5c0724f135d3905941841ba0470eaee4eb4f
|
7
|
+
data.tar.gz: 57c5279177ead71990a756c142f5ac17b2306116e359d4e7edcad448180ad5523c3f8132e024dfbf034b7cb30c8e790788990c00c01a825650eacadc981b1cbc
|
data/lib/rservicebus2.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Add the currently running directory to the start of the load path
|
2
4
|
# $:.unshift File.dirname(__FILE__) + '/../../lib'
|
3
5
|
|
@@ -19,7 +21,6 @@ require 'rservicebus2/mq'
|
|
19
21
|
require 'rservicebus2/host'
|
20
22
|
require 'rservicebus2/config'
|
21
23
|
require 'rservicebus2/endpointmapping'
|
22
|
-
require 'rservicebus2/stats'
|
23
24
|
require 'rservicebus2/statistic_manager'
|
24
25
|
require 'rservicebus2/audit'
|
25
26
|
|
@@ -45,10 +46,10 @@ require 'rservicebus2/monitor_configure'
|
|
45
46
|
|
46
47
|
require 'rservicebus2/agent'
|
47
48
|
|
48
|
-
require 'rservicebus2/saga_loader
|
49
|
-
require 'rservicebus2/saga/manager
|
50
|
-
require 'rservicebus2/saga/data
|
51
|
-
require 'rservicebus2/saga/base
|
49
|
+
require 'rservicebus2/saga_loader'
|
50
|
+
require 'rservicebus2/saga/manager'
|
51
|
+
require 'rservicebus2/saga/data'
|
52
|
+
require 'rservicebus2/saga/base'
|
52
53
|
|
53
54
|
require 'rservicebus2/saga_storage'
|
54
55
|
|
data/lib/rservicebus2/agent.rb
CHANGED
@@ -33,8 +33,8 @@ module RServiceBus2
|
|
33
33
|
q = queue_name
|
34
34
|
else
|
35
35
|
parts = queueName.split('@')
|
36
|
-
msg.
|
37
|
-
msg.
|
36
|
+
msg.remote_queue_name = parts[0]
|
37
|
+
msg.remote_host_name = parts[1]
|
38
38
|
q = 'transport-out'
|
39
39
|
end
|
40
40
|
|
@@ -1,16 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'aws-sdk-s3'
|
2
4
|
|
3
5
|
module RServiceBus2
|
4
6
|
# AppResourceAWSDynamoDb
|
5
7
|
class AppResourceAWSS3 < AppResource
|
6
|
-
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
7
8
|
def connect(uri)
|
8
9
|
region = uri.host
|
9
10
|
|
10
11
|
Aws::S3::Client.new(region: region)
|
11
12
|
end
|
12
13
|
|
13
|
-
def finished
|
14
|
-
end
|
14
|
+
def finished; end
|
15
15
|
end
|
16
16
|
end
|
data/lib/rservicebus2/config.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module RServiceBus2
|
4
4
|
# Marshals configuration information for an rservicebus host
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
5
6
|
class Config
|
6
7
|
attr_reader :app_name, :message_endpoint_mappings, :handler_path_list,
|
7
8
|
:saga_path_list, :error_queue_name, :max_retries,
|
@@ -49,6 +50,7 @@ module RServiceBus2
|
|
49
50
|
self
|
50
51
|
end
|
51
52
|
|
53
|
+
# rubocop:disable Metrics/MethodLength
|
52
54
|
def load_host_section
|
53
55
|
@app_name = get_value('APPNAME', 'RServiceBus2')
|
54
56
|
@error_queue_name = get_value('ERROR_QUEUE_NAME', 'error')
|
@@ -68,6 +70,7 @@ module RServiceBus2
|
|
68
70
|
|
69
71
|
self
|
70
72
|
end
|
73
|
+
# rubocop:enable Metrics/MethodLength
|
71
74
|
|
72
75
|
def ensure_contract_file_exists(path)
|
73
76
|
unless File.exist?(path) || File.exist?("#{path}.rb")
|
@@ -75,11 +78,11 @@ module RServiceBus2
|
|
75
78
|
puts "*** path, #{path}, provided does not exist as a file"
|
76
79
|
abort
|
77
80
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
return if File.extname(path) == '.rb'
|
82
|
+
|
83
|
+
puts 'Error while processing contracts'
|
84
|
+
puts "*** path, #{path}, should point to a ruby file, with extention .rb"
|
85
|
+
abort
|
83
86
|
end
|
84
87
|
|
85
88
|
# Marshals paths for contracts
|
@@ -102,6 +105,16 @@ module RServiceBus2
|
|
102
105
|
# Marshals paths for lib
|
103
106
|
# Note. .rb extension is optional
|
104
107
|
# Expected format: /one/two/contracts
|
108
|
+
def load_lib(path)
|
109
|
+
log "Loading libs from, #{path}"
|
110
|
+
return path if File.exist?(path)
|
111
|
+
|
112
|
+
puts 'Error while processing libs'
|
113
|
+
puts "*** path, #{path}, should point to a ruby file, with extention .rb, or"
|
114
|
+
puts "*** path, #{path}, should point to a directory than conatins ruby files, that have extention .rb"
|
115
|
+
abort
|
116
|
+
end
|
117
|
+
|
105
118
|
def load_libs
|
106
119
|
@lib_list = []
|
107
120
|
|
@@ -109,18 +122,7 @@ module RServiceBus2
|
|
109
122
|
paths = './lib' if paths.nil? && File.exist?('./lib')
|
110
123
|
return self if paths.nil?
|
111
124
|
|
112
|
-
paths.split(';').each
|
113
|
-
log "Loading libs from, #{path}"
|
114
|
-
unless File.exist?(path)
|
115
|
-
puts 'Error while processing libs'
|
116
|
-
puts "*** path, #{path}, should point to a ruby file, with extention
|
117
|
-
.rb, or"
|
118
|
-
puts "*** path, #{path}, should point to a directory than conatins
|
119
|
-
ruby files, that have extention .rb"
|
120
|
-
abort
|
121
|
-
end
|
122
|
-
@lib_list << path
|
123
|
-
end
|
125
|
+
paths.split(';').each { |path| @lib_list << load_lib(path) }
|
124
126
|
self
|
125
127
|
end
|
126
128
|
|
@@ -132,29 +134,35 @@ module RServiceBus2
|
|
132
134
|
# Marshals paths for working_dirs
|
133
135
|
# Note. trailing slashs will be stripped
|
134
136
|
# Expected format: <path 1>;<path 2>
|
137
|
+
def load_working_dir_path(path)
|
138
|
+
path = path.strip.chomp('/')
|
139
|
+
unless Dir.exist?(path.to_s)
|
140
|
+
puts 'Error while processing working directory list'
|
141
|
+
puts "*** path, #{path}, does not exist"
|
142
|
+
abort
|
143
|
+
end
|
144
|
+
@handler_path_list << "#{path}/messagehandler" if Dir.exist?("#{path}/messagehandler")
|
145
|
+
@saga_path_list << "#{path}/saga" if Dir.exist?("#{path}/saga")
|
146
|
+
@contract_list << "#{path}/contract.rb" if File.exist?("#{path}/contract.rb")
|
147
|
+
@lib_list << "#{path}/lib" if File.exist?("#{path}/lib")
|
148
|
+
end
|
149
|
+
|
135
150
|
def load_working_dir_list
|
136
151
|
path_list = get_value('WORKING_DIR', './')
|
137
152
|
return self if path_list.nil?
|
138
153
|
|
139
154
|
path_list.split(';').each do |path|
|
140
|
-
path
|
141
|
-
unless Dir.exist?(path.to_s)
|
142
|
-
puts 'Error while processing working directory list'
|
143
|
-
puts "*** path, #{path}, does not exist"
|
144
|
-
abort
|
145
|
-
end
|
146
|
-
@handler_path_list << "#{path}/messagehandler" if Dir.exist?("#{path}/messagehandler")
|
147
|
-
@saga_path_list << "#{path}/saga" if Dir.exist?("#{path}/saga")
|
148
|
-
@contract_list << "#{path}/contract.rb" if File.exist?("#{path}/contract.rb")
|
149
|
-
@lib_list << "#{path}/lib" if File.exist?("#{path}/lib")
|
155
|
+
load_working_dir_path(path)
|
150
156
|
end
|
151
157
|
self
|
152
158
|
end
|
153
159
|
end
|
160
|
+
# rubocop:enable Metrics/ClassLength
|
154
161
|
|
155
162
|
# Class
|
163
|
+
# rubocop:disable Lint/MissingSuper
|
156
164
|
class ConfigFromEnv < Config
|
157
|
-
def initialize; end
|
165
|
+
def initialize; end
|
158
166
|
end
|
159
167
|
|
160
168
|
# Class
|
@@ -162,6 +170,7 @@ module RServiceBus2
|
|
162
170
|
attr_writer :app_name, :message_endpoint_mappings, :handler_path_list, :error_queue_name, \
|
163
171
|
:max_retries, :forward_received_messages_to, :beanstalk_host
|
164
172
|
|
165
|
-
def initialize; end
|
173
|
+
def initialize; end
|
166
174
|
end
|
175
|
+
# rubocop:enable Lint/MissingSuper
|
167
176
|
end
|
@@ -12,8 +12,7 @@ module RServiceBus2
|
|
12
12
|
RServiceBus2.log(string)
|
13
13
|
end
|
14
14
|
|
15
|
-
# rubocop:disable Metrics/AbcSize
|
16
|
-
# rubocop:disable Metrics/MethodLength
|
15
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
17
16
|
def configure_mapping(mapping)
|
18
17
|
match = mapping.match(/(.+):(.+)/)
|
19
18
|
if match.nil?
|
@@ -36,8 +35,7 @@ module RServiceBus2
|
|
36
35
|
end
|
37
36
|
@queue_name_list << match[2]
|
38
37
|
end
|
39
|
-
# rubocop:enable Metrics/AbcSize
|
40
|
-
# rubocop:enable Metrics/MethodLength
|
38
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
41
39
|
|
42
40
|
# rubocop:disable Metrics/MethodLength
|
43
41
|
def configure(local_queue_name = nil)
|
@@ -102,7 +102,7 @@ module RServiceBus2
|
|
102
102
|
next if @resource_list_by_handler_name[handler.class.name].nil?
|
103
103
|
|
104
104
|
@resource_list_by_handler_name[handler.class.name].each do |k|
|
105
|
-
handler.instance_variable_set("@#{k}", @resource_manager.get(k).
|
105
|
+
handler.instance_variable_set("@#{k}", @resource_manager.get(k).resource)
|
106
106
|
RServiceBus2.rlog "App resource attribute, #{k}, set for: #{handler.class.name}"
|
107
107
|
end
|
108
108
|
end
|
@@ -18,10 +18,10 @@ module RServiceBus2
|
|
18
18
|
return if check_environment_variable('TESTING')
|
19
19
|
|
20
20
|
type = ver ? 'VERB' : 'INFO'
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
return unless check_environment_variable('VERBOSE') || !ver
|
22
|
+
|
23
|
+
timestamp = Time.new.strftime('%Y-%m-%d %H:%M:%S')
|
24
|
+
puts "[#{type}] #{timestamp} :: #{string}"
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.rlog(string)
|
@@ -43,6 +43,7 @@ module RServiceBus2
|
|
43
43
|
value
|
44
44
|
end
|
45
45
|
|
46
|
+
# rubocop:disable Metrics/MethodLength
|
46
47
|
def self.send_msg(msg, response_queue = 'agent')
|
47
48
|
require 'rservicebus2/endpointmapping'
|
48
49
|
endpoint_mapping = EndpointMapping.new
|
@@ -54,13 +55,12 @@ module RServiceBus2
|
|
54
55
|
Audit.new(agent).audit_to_queue(msg)
|
55
56
|
agent.send_msg(msg, queue_name, response_queue)
|
56
57
|
rescue QueueNotFoundForMsg => e
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
msg = "#{msg}*** MESSAGE_ENDPOINT_MAPPINGS=#{e.message}:<QueueName>\n"
|
62
|
-
raise StandardError, msg
|
58
|
+
raise StandardError, '' \
|
59
|
+
"*** Queue not found for, #{e.message}\n" \
|
60
|
+
"*** Ensure you have an environment variable set for this Message Type, eg, \n" \
|
61
|
+
"*** MESSAGE_ENDPOINT_MAPPINGS=#{e.message}:<QueueName>\n"
|
63
62
|
end
|
63
|
+
# rubocop:enable Metrics/MethodLength
|
64
64
|
|
65
65
|
def self.check_for_reply(queue_name)
|
66
66
|
ENV['RSBMQ'] = 'beanstalk://localhost' if ENV['RSBMQ'].nil?
|
@@ -76,9 +76,9 @@ module RServiceBus2
|
|
76
76
|
#{caller[0]}. #{string}"
|
77
77
|
end
|
78
78
|
|
79
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
79
80
|
def self.check_environment_variable(string)
|
80
|
-
return false if ENV[string].nil?
|
81
|
-
return false if ENV[string] == ''
|
81
|
+
return false if ENV[string].nil? || ENV[string] == ''
|
82
82
|
return true if ENV[string] == true || ENV[string] =~ (/(true|t|yes|y|1)$/i)
|
83
83
|
return false if ENV[string] == false ||
|
84
84
|
ENV[string].nil? ||
|
@@ -86,4 +86,5 @@ module RServiceBus2
|
|
86
86
|
|
87
87
|
raise ArgumentError, "invalid value for Environment Variable: \"#{string}\""
|
88
88
|
end
|
89
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
89
90
|
end
|
data/lib/rservicebus2/host.rb
CHANGED
@@ -119,7 +119,7 @@ module RServiceBus2
|
|
119
119
|
configure_saga_storage
|
120
120
|
configure_app_resource
|
121
121
|
@circuit_breaker = CircuitBreaker.new(self)
|
122
|
-
@monitors = ConfigureMonitor.new(self, @resource_manager).
|
122
|
+
@monitors = ConfigureMonitor.new(self, @resource_manager).monitors(ENV)
|
123
123
|
load_handlers
|
124
124
|
load_sagas
|
125
125
|
@cron_manager = CronManager.new(self, @handler_manager.msg_names)
|
@@ -339,8 +339,8 @@ module RServiceBus2
|
|
339
339
|
RServiceBus2.rlog "Sending, #{msg.class.name} to, #{queue_name}"
|
340
340
|
else
|
341
341
|
parts = queue_name.split('@')
|
342
|
-
r_msg.
|
343
|
-
r_msg.
|
342
|
+
r_msg.remote_queue_name = parts[0]
|
343
|
+
r_msg.remote_host_name = parts[1]
|
344
344
|
q = 'transport-out'
|
345
345
|
RServiceBus2.rlog "Sending, #{msg.class.name} to, #{queue_name}, via #{q}"
|
346
346
|
end
|
@@ -370,11 +370,11 @@ module RServiceBus2
|
|
370
370
|
# Reply queues are specified in each msg. It works like
|
371
371
|
# email, where the reply address can actually be anywhere
|
372
372
|
# @param [RServiceBus2::Message] msg msg to be sent
|
373
|
-
def reply(msg)
|
373
|
+
def reply(msg, timestamp = nil)
|
374
374
|
RServiceBus2.rlog "Reply with: #{msg.class.name} To: #{@msg.return_address}"
|
375
375
|
@stats.inc_total_reply
|
376
376
|
|
377
|
-
queue_msg_for_send_on_complete(msg, @msg.return_address)
|
377
|
+
queue_msg_for_send_on_complete(msg, @msg.return_address, timestamp)
|
378
378
|
end
|
379
379
|
|
380
380
|
def get_endpoint_for_msg(msg_name)
|
data/lib/rservicebus2/message.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'zlib'
|
2
4
|
require 'yaml'
|
3
5
|
require 'uuidtools'
|
@@ -5,15 +7,18 @@ require 'uuidtools'
|
|
5
7
|
module RServiceBus2
|
6
8
|
# This is the top level message that is passed around the bus
|
7
9
|
class Message
|
8
|
-
attr_reader :return_address, :msg_id,
|
10
|
+
attr_reader :return_address, :msg_id,
|
9
11
|
:last_error_source_queue, :last_error_string, :correlation_id,
|
10
12
|
:sendat, :error_list
|
11
13
|
|
14
|
+
attr_accessor :remote_host_name, :remote_queue_name, :send_at
|
15
|
+
|
12
16
|
# Constructor
|
13
17
|
#
|
14
18
|
# @param [Object] msg The msg to be sent
|
15
19
|
# @param [Object] returnAddress A queue to which the destination message
|
16
20
|
# handler can send replies
|
21
|
+
# rubocop:disable Metrics/MethodLength
|
17
22
|
def initialize(msg, return_address, correlation_id = nil)
|
18
23
|
if RServiceBus2.check_environment_variable('RSBMSG_COMPRESS')
|
19
24
|
@compressed = true
|
@@ -26,11 +31,12 @@ module RServiceBus2
|
|
26
31
|
@correlation_id = correlation_id
|
27
32
|
@return_address = return_address
|
28
33
|
|
29
|
-
@createdat =
|
34
|
+
@createdat = Time.now
|
30
35
|
|
31
36
|
@msg_id = UUIDTools::UUID.random_create
|
32
37
|
@error_list = []
|
33
38
|
end
|
39
|
+
# rubocop:enable Metrics/MethodLength
|
34
40
|
|
35
41
|
# If an error occurs while processing the message, this method allows details of the error to held
|
36
42
|
# next to the msg.
|
@@ -47,25 +53,11 @@ module RServiceBus2
|
|
47
53
|
@error_list << RServiceBus2::ErrorMessage.new(source_queue, error_string)
|
48
54
|
end
|
49
55
|
|
50
|
-
def set_remote_host_name(host_name)
|
51
|
-
@remote_host_name = host_name
|
52
|
-
end
|
53
|
-
|
54
|
-
def set_remote_queue_name(queue_name)
|
55
|
-
@remote_queue_name = queue_name
|
56
|
-
end
|
57
|
-
|
58
|
-
def send_at(timestamp)
|
59
|
-
@send_at = timestamp
|
60
|
-
end
|
61
|
-
|
62
56
|
# @return [Object] The msg to be sent
|
63
57
|
def msg
|
64
|
-
if @compressed == true
|
65
|
-
|
66
|
-
|
67
|
-
return YAML.load( @_msg )
|
68
|
-
end
|
58
|
+
return YAML.load(Zlib::Inflate.inflate(@_msg)) if @compressed == true
|
59
|
+
|
60
|
+
YAML.load(@_msg)
|
69
61
|
rescue ArgumentError => e
|
70
62
|
raise e if e.message.index('undefined class/module ').nil?
|
71
63
|
|