rservicebus2 0.2.7 → 0.2.12
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 +8 -9
- 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/circuitbreaker.rb +4 -2
- data/lib/rservicebus2/config.rb +44 -35
- data/lib/rservicebus2/cron_manager.rb +6 -1
- data/lib/rservicebus2/endpointmapping.rb +20 -14
- data/lib/rservicebus2/errormessage.rb +3 -2
- data/lib/rservicebus2/handler_loader.rb +35 -28
- data/lib/rservicebus2/handler_manager.rb +31 -25
- data/lib/rservicebus2/helper_functions.rb +20 -15
- data/lib/rservicebus2/host.rb +63 -124
- 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 +3 -0
- data/lib/rservicebus2/monitor/message.rb +2 -0
- data/lib/rservicebus2/monitor/xmldir.rb +2 -0
- data/lib/rservicebus2/monitor_configure.rb +47 -37
- data/lib/rservicebus2/mq.rb +27 -30
- data/lib/rservicebus2/mq/beanstalk.rb +5 -1
- data/lib/rservicebus2/resource_manager.rb +14 -19
- data/lib/rservicebus2/saga/data.rb +1 -1
- data/lib/rservicebus2/saga/manager.rb +2 -2
- 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: a3c83b298bb79d2335fa0c00cfc6493249617f0cff9cfbd2f1d21ee6f0e241d0
|
4
|
+
data.tar.gz: 93bd9a061367a3243b99d29c0d9cf18c1aa3d6361d10afba694b775961591eb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 490c5af6b79552613745e6b8b01f53da8f3a3f861268cf854d905fcaa19f65994a4675b0669ee4174fcd2eb7b0367520651faefbf30fbb7864ab9aa0c40e5376
|
7
|
+
data.tar.gz: '08698a30dc4cb75f00b14b7fa18b2aebcffef02c7a5b86089e18449e472fe978db16e270bb7a3b115e996fa6eeebd26c12e89ceff980f8cd3e45d71ef1af319a'
|
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,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
|
-
|
13
|
+
raise 'Method, connect, needs to be implemented for resource'
|
12
14
|
end
|
13
15
|
|
14
16
|
def _connect
|
@@ -16,7 +18,7 @@ module RServiceBus2
|
|
16
18
|
RServiceBus2.rlog "#{self.class.name}. Connected to, #{@uri}"
|
17
19
|
end
|
18
20
|
|
19
|
-
def
|
21
|
+
def resource
|
20
22
|
@connection
|
21
23
|
end
|
22
24
|
|
@@ -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
|
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,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')
|
@@ -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
|
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
|
-
|
73
|
+
raise MessageArrivedWhileCricuitBroken if @broken == true
|
72
74
|
end
|
73
75
|
|
74
76
|
def break_circuit
|
data/lib/rservicebus2/config.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RServiceBus2
|
2
4
|
# Marshals configuration information for an rservicebus host
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
3
6
|
class Config
|
4
7
|
attr_reader :app_name, :message_endpoint_mappings, :handler_path_list,
|
5
8
|
:saga_path_list, :error_queue_name, :max_retries,
|
@@ -19,7 +22,7 @@ module RServiceBus2
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def get_value(name, default = nil)
|
22
|
-
value =
|
25
|
+
value = ENV[name].nil? || ENV[name] == '' ? default : ENV[name]
|
23
26
|
log "Env value: #{name}: #{value}"
|
24
27
|
value
|
25
28
|
end
|
@@ -47,6 +50,7 @@ module RServiceBus2
|
|
47
50
|
self
|
48
51
|
end
|
49
52
|
|
53
|
+
# rubocop:disable Metrics/MethodLength
|
50
54
|
def load_host_section
|
51
55
|
@app_name = get_value('APPNAME', 'RServiceBus2')
|
52
56
|
@error_queue_name = get_value('ERROR_QUEUE_NAME', 'error')
|
@@ -66,6 +70,7 @@ module RServiceBus2
|
|
66
70
|
|
67
71
|
self
|
68
72
|
end
|
73
|
+
# rubocop:enable Metrics/MethodLength
|
69
74
|
|
70
75
|
def ensure_contract_file_exists(path)
|
71
76
|
unless File.exist?(path) || File.exist?("#{path}.rb")
|
@@ -73,11 +78,11 @@ module RServiceBus2
|
|
73
78
|
puts "*** path, #{path}, provided does not exist as a file"
|
74
79
|
abort
|
75
80
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
81
86
|
end
|
82
87
|
|
83
88
|
# Marshals paths for contracts
|
@@ -100,6 +105,16 @@ module RServiceBus2
|
|
100
105
|
# Marshals paths for lib
|
101
106
|
# Note. .rb extension is optional
|
102
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
|
+
|
103
118
|
def load_libs
|
104
119
|
@lib_list = []
|
105
120
|
|
@@ -107,18 +122,7 @@ module RServiceBus2
|
|
107
122
|
paths = './lib' if paths.nil? && File.exist?('./lib')
|
108
123
|
return self if paths.nil?
|
109
124
|
|
110
|
-
paths.split(';').each
|
111
|
-
log "Loading libs from, #{path}"
|
112
|
-
unless File.exist?(path)
|
113
|
-
puts 'Error while processing libs'
|
114
|
-
puts "*** path, #{path}, should point to a ruby file, with extention
|
115
|
-
.rb, or"
|
116
|
-
puts "*** path, #{path}, should point to a directory than conatins
|
117
|
-
ruby files, that have extention .rb"
|
118
|
-
abort
|
119
|
-
end
|
120
|
-
@lib_list << path
|
121
|
-
end
|
125
|
+
paths.split(';').each { |path| @lib_list << load_lib(path) }
|
122
126
|
self
|
123
127
|
end
|
124
128
|
|
@@ -130,38 +134,43 @@ module RServiceBus2
|
|
130
134
|
# Marshals paths for working_dirs
|
131
135
|
# Note. trailing slashs will be stripped
|
132
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
|
+
|
133
150
|
def load_working_dir_list
|
134
|
-
puts "Config.load_working_dir_list.1"
|
135
|
-
puts "Config.load_working_dir_list.2 #{@contract_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}")
|
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
|
158
|
-
end
|
165
|
+
def initialize; end
|
159
166
|
end
|
160
167
|
|
161
168
|
# Class
|
162
169
|
class ConfigFromSetter < Config
|
163
|
-
attr_writer :
|
164
|
-
|
165
|
-
|
170
|
+
attr_writer :app_name, :message_endpoint_mappings, :handler_path_list, :error_queue_name, \
|
171
|
+
:max_retries, :forward_received_messages_to, :beanstalk_host
|
172
|
+
|
173
|
+
def initialize; end
|
166
174
|
end
|
175
|
+
# rubocop:enable Lint/MissingSuper
|
167
176
|
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
|
-
|
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
|