rservicebus2 0.2.8 → 0.2.13
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 +7 -4
- data/lib/rservicebus2/appresource.rb +1 -1
- 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/appresource_configure.rb +8 -4
- data/lib/rservicebus2/audit.rb +4 -2
- data/lib/rservicebus2/config.rb +39 -27
- 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 +19 -14
- data/lib/rservicebus2/host.rb +62 -123
- 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/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 +46 -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/manager.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 +2 -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: 51c1a3dd6e3b22da8216ba061cb1572a5dd29475353c0b10ea470bdda7d7e3f7
|
4
|
+
data.tar.gz: 3952dfc273048ca7cecd3dca0179891d8d9bcc341e137b3212ce611c10523681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ed0ba711726a1641c1c3fab6811843f826633caca5c3061d5d223731313cc0138f182842768bece201041001a081ba899261bbbde5a0415fdeadd4252127ef5
|
7
|
+
data.tar.gz: 3976c2ec0eb733817f5b364bd0ee788a9ce1d13c2ff48c08694c5df916441d38ba6bbbfa6f0e8822a1143f51a00b53fd037ef9194a5e1fde969c8f75b0672aa4
|
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
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RServiceBus2
|
2
4
|
class QueueNotFoundForMsg < StandardError
|
3
5
|
end
|
@@ -22,17 +24,17 @@ module RServiceBus2
|
|
22
24
|
# @param [Object] messageObj The msg to be sent
|
23
25
|
# @param [String] queueName the name of the queue to be send the msg to
|
24
26
|
# @param [String] returnAddress the name of a queue to send replies to
|
25
|
-
# rubocop:disable Metrics/
|
27
|
+
# rubocop:disable Metrics/MethodLength
|
26
28
|
def send_msg(message_obj, queue_name, return_address = nil)
|
27
|
-
|
29
|
+
raise QueueNotFoundForMsg, message_obj.class.name if queue_name.nil?
|
28
30
|
|
29
31
|
msg = RServiceBus2::Message.new(message_obj, return_address)
|
30
32
|
if queue_name.index('@').nil?
|
31
33
|
q = queue_name
|
32
34
|
else
|
33
35
|
parts = queueName.split('@')
|
34
|
-
msg.
|
35
|
-
msg.
|
36
|
+
msg.remote_queue_name = parts[0]
|
37
|
+
msg.remote_host_name = parts[1]
|
36
38
|
q = 'transport-out'
|
37
39
|
end
|
38
40
|
|
@@ -40,6 +42,7 @@ module RServiceBus2
|
|
40
42
|
|
41
43
|
@mq.send(q, serialized_object)
|
42
44
|
end
|
45
|
+
# rubocop:enable Metrics/MethodLength
|
43
46
|
|
44
47
|
# Gives an agent the means to receive a reply
|
45
48
|
#
|
@@ -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
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'uri'
|
2
4
|
|
3
5
|
module RServiceBus2
|
4
6
|
# Configure AppResources for an rservicebus host
|
5
7
|
class ConfigureAppResource
|
6
|
-
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength,CyclomaticComplexity
|
8
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
7
9
|
def get_resources(env, host, state_manager, saga_storage)
|
8
|
-
# rm = resource_manager
|
9
10
|
rm = ResourceManager.new(state_manager, saga_storage)
|
11
|
+
# rubocop:disable Metrics/BlockLength
|
10
12
|
env.each do |k, v|
|
11
13
|
if v.is_a?(String) && k.start_with?('RSBFDB2_')
|
12
14
|
uri = URI.parse(v)
|
@@ -15,8 +17,8 @@ module RServiceBus2
|
|
15
17
|
k = k.sub('RSBFDB2_', '')
|
16
18
|
rm.add k, AppResourceFluidDb2.new(host, uri)
|
17
19
|
elsif v.is_a?(String) &&
|
18
|
-
(k.start_with?('RSBFDB_') || v.
|
19
|
-
v = v['fluiddb'.length..-1] if v.
|
20
|
+
(k.start_with?('RSBFDB_') || v.start_with?('fluiddb'))
|
21
|
+
v = v['fluiddb'.length..-1] if v.start_with?('fluiddb')
|
20
22
|
uri = URI.parse(v)
|
21
23
|
require 'rservicebus2/appresource/fluiddb'
|
22
24
|
|
@@ -46,8 +48,10 @@ module RServiceBus2
|
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
51
|
+
# rubocop:enable Metrics/BlockLength
|
49
52
|
|
50
53
|
rm
|
51
54
|
end
|
55
|
+
# rubocop:enable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
52
56
|
end
|
53
57
|
end
|
data/lib/rservicebus2/audit.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RServiceBus2
|
2
4
|
# Audit Class
|
3
5
|
class Audit
|
4
|
-
def initialize(
|
5
|
-
@mq =
|
6
|
+
def initialize(message_queue)
|
7
|
+
@mq = message_queue
|
6
8
|
audit_queue_name = RServiceBus2.get_value('AUDIT_QUEUE_NAME')
|
7
9
|
if audit_queue_name.nil?
|
8
10
|
@sent_messages_to = RServiceBus2.get_value('sent_messages_to')
|
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,33 +134,43 @@ 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
|
165
|
+
def initialize; end
|
157
166
|
end
|
158
167
|
|
159
168
|
# Class
|
160
169
|
class ConfigFromSetter < Config
|
161
170
|
attr_writer :app_name, :message_endpoint_mappings, :handler_path_list, :error_queue_name, \
|
162
171
|
:max_retries, :forward_received_messages_to, :beanstalk_host
|
172
|
+
|
173
|
+
def initialize; end
|
163
174
|
end
|
175
|
+
# rubocop:enable Lint/MissingSuper
|
164
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
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Helper functions
|
1
4
|
module RServiceBus2
|
2
5
|
def self.convert_dto_to_hash(obj)
|
3
6
|
hash = {}
|
@@ -15,10 +18,10 @@ module RServiceBus2
|
|
15
18
|
return if check_environment_variable('TESTING')
|
16
19
|
|
17
20
|
type = ver ? 'VERB' : 'INFO'
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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}"
|
22
25
|
end
|
23
26
|
|
24
27
|
def self.rlog(string)
|
@@ -35,11 +38,12 @@ module RServiceBus2
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def self.get_value(name, default = nil)
|
38
|
-
value =
|
41
|
+
value = ENV[name].nil? || ENV[name] == '' ? default : ENV[name]
|
39
42
|
log "Env value: #{name}: #{value}"
|
40
43
|
value
|
41
44
|
end
|
42
45
|
|
46
|
+
# rubocop:disable Metrics/MethodLength
|
43
47
|
def self.send_msg(msg, response_queue = 'agent')
|
44
48
|
require 'rservicebus2/endpointmapping'
|
45
49
|
endpoint_mapping = EndpointMapping.new
|
@@ -50,15 +54,13 @@ module RServiceBus2
|
|
50
54
|
agent = RServiceBus2::Agent.new
|
51
55
|
Audit.new(agent).audit_to_queue(msg)
|
52
56
|
agent.send_msg(msg, queue_name, response_queue)
|
53
|
-
|
54
57
|
rescue QueueNotFoundForMsg => e
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
msg = "#{msg}*** MESSAGE_ENDPOINT_MAPPINGS=#{e.message}:<QueueName>\n"
|
60
|
-
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"
|
61
62
|
end
|
63
|
+
# rubocop:enable Metrics/MethodLength
|
62
64
|
|
63
65
|
def self.check_for_reply(queue_name)
|
64
66
|
ENV['RSBMQ'] = 'beanstalk://localhost' if ENV['RSBMQ'].nil?
|
@@ -74,12 +76,15 @@ module RServiceBus2
|
|
74
76
|
#{caller[0]}. #{string}"
|
75
77
|
end
|
76
78
|
|
79
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
77
80
|
def self.check_environment_variable(string)
|
78
|
-
return false if ENV[string].nil?
|
81
|
+
return false if ENV[string].nil? || ENV[string] == ''
|
79
82
|
return true if ENV[string] == true || ENV[string] =~ (/(true|t|yes|y|1)$/i)
|
80
83
|
return false if ENV[string] == false ||
|
81
84
|
ENV[string].nil? ||
|
82
85
|
ENV[string] =~ (/(false|f|no|n|0)$/i)
|
83
|
-
|
86
|
+
|
87
|
+
raise ArgumentError, "invalid value for Environment Variable: \"#{string}\""
|
84
88
|
end
|
89
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
85
90
|
end
|