rservicebus2 0.1.4 → 0.2.0

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
  SHA1:
3
- metadata.gz: fada1aee3a7884d50bf77a55981556c5b813ddcf
4
- data.tar.gz: dd63dae7e3e5dcac2d0fc9d316202edb38eab16a
3
+ metadata.gz: e7e4478dcfd17cf33e195c10a8e26aa9394e6b0f
4
+ data.tar.gz: 5f712faee16f86b3ed2f56289ffced68781e5c94
5
5
  SHA512:
6
- metadata.gz: d0bfe746cdd9d90688a6dbea40589db4c9fdd99054fd38406eaaa87f46756d969422d6ca5d404622c7989638385ca0c6aff37fb34e95b02ce84caa4f689f193e
7
- data.tar.gz: c7f3ea7b8960d47ce837cffb3d085c64665cd0c053b531ccd7baecc146720597ca261a05166ccec26e2e74f6d92fea7d34506d3a8fe6d58b8cfc5be3f36d074b
6
+ metadata.gz: c730bfeb3dd50ceb5dc8aab7f2fcc7663c2539229fcf12a87c6da81855b8d3d626104710a83a01b13a09bca2e3d042f8f125e8f12d2bbe17738b15c3d7ef9b43
7
+ data.tar.gz: aeb9173b91dfeaeefa82a67fba42dbcf9401ad20d7560e559e7b12e271e391d9e2474805f1a860c2845aa2416006ad7b8f0c4f15f9dd2c42dc56069b08fc63f1
@@ -43,8 +43,8 @@ module RServiceBus2
43
43
 
44
44
  # Thin veneer for Configuring state
45
45
  def configure_saga_storage
46
- string = RServiceBus2.get_value('SAGA_URI')
47
- string = 'dir:///tmp' if string.nil?
46
+ string = RServiceBus2.get_value('SAGA_URI', 'dir:///tmp/saga')
47
+ # string = 'dir:///tmp' if string.nil?
48
48
 
49
49
  uri = URI.parse(string)
50
50
  @saga_storage = SagaStorage.get(uri)
@@ -24,7 +24,7 @@ module RServiceBus2
24
24
  end
25
25
 
26
26
  def get_start_with_method_names(saga)
27
- get_methods_by_prefix(saga, 'startwith_')
27
+ get_methods_by_prefix(saga, 'start_with_')
28
28
  end
29
29
 
30
30
  # setBusAttributeIfRequested
@@ -63,7 +63,7 @@ module RServiceBus2
63
63
  @start_with[msg_name] = [] if @start_with[msg_name].nil?
64
64
  @start_with[msg_name] << s
65
65
 
66
- RServiceBus2.log "Registered, #{saga.name}, to startwith, #{msg_name}", true
66
+ RServiceBus2.log "Registered, #{saga.name}, to start_with, #{msg_name}", true
67
67
  end
68
68
 
69
69
  @saga[saga.name] = s
@@ -88,12 +88,13 @@ module RServiceBus2
88
88
  msg_class_name = msg.class.name.downcase
89
89
 
90
90
  RServiceBus2.log "SagaManager, started processing, #{msg_class_name}", true
91
- unless @start_with[msg_class_name].nil?
91
+ if @start_with.key?(msg_class_name)
92
+ # unless @start_with[msg_class_name].nil?
92
93
  @start_with[msg_class_name].each do |saga|
93
94
  data = SagaData.new(saga)
94
95
  @saga_storage.set(data)
95
96
 
96
- method_name = "startwith_#{msg_class_name}"
97
+ method_name = "start_with_#{msg_class_name}"
97
98
  process_msg(saga, data, method_name, msg)
98
99
 
99
100
  handled = true
@@ -102,8 +103,10 @@ module RServiceBus2
102
103
  return handled if handled == true
103
104
 
104
105
  return false if rmsg.correlation_id.nil?
106
+
105
107
  data = @saga_storage.get(rmsg.correlation_id)
106
- return handled if data.nil?
108
+ return false if data.nil?
109
+
107
110
  method_name = "handle_#{msg_class_name}"
108
111
  saga = @saga[data.saga_class_name]
109
112
  process_msg(saga, data, method_name, msg)
@@ -16,21 +16,21 @@ module RServiceBus2
16
16
  # Cleans the given path to ensure it can be used for as a parameter for the
17
17
  # require statement.
18
18
  # @param [String] file_path the path to be cleaned
19
- def get_require_path(filePath)
19
+ def get_require_path(file_path)
20
20
  file_path = './' + file_path unless file_path.start_with?('/')
21
21
 
22
22
  return file_path.sub('.rb', '') if File.exist?(file_path)
23
23
 
24
- abort('Filepath, ' + filePath + ", given for Saga require doesn't exist")
24
+ abort('Filepath, ' + file_path + ", given for Saga require doesn't exist")
25
25
  end
26
26
 
27
- # Instantiate the saga named in sagaName from the file name in filePath
27
+ # Instantiate the saga named in sagaName from the file name in file_path
28
28
  # Exceptions will be raised if encountered when loading sagas. This is a
29
29
  # load time activity, so sagas should load correctly. As much information
30
30
  # as possible is returned to enable the saga to be fixed, or configuration
31
31
  # corrected.
32
32
  # @param [String] sagaName name of the saga to instantiate
33
- # @param [String] filePath the path to the file to be loaded
33
+ # @param [String] file_path the path to the file to be loaded
34
34
  # @return [RServiceBus2::Saga] the loader
35
35
  def load_saga_from_file(saga_name, file_path)
36
36
  require_path = get_require_path(file_path)
@@ -50,7 +50,7 @@ module RServiceBus2
50
50
  end
51
51
 
52
52
  # Wrapper function
53
- # @param [String] filePath
53
+ # @param [String] file_path
54
54
  # @param [String] sagaName
55
55
  # @returns [RServiceBus2::Saga] saga
56
56
  def load_saga(file_path, saga_name)
@@ -97,7 +97,7 @@ module RServiceBus2
97
97
 
98
98
  saga_name = base_name.sub(ext_name, '')
99
99
 
100
- "Saga_#{saga_name}"
100
+ "saga_#{saga_name}".gsub(/(?<=_|^)(\w)/){$1.upcase}.gsub(/(?:_)(\w)/,'\1')
101
101
  end
102
102
 
103
103
  # Entry point for loading Sagas
@@ -106,7 +106,7 @@ module RServiceBus2
106
106
  RServiceBus2.rlog "SagaLoader.loadSagasFromPath. base_dir: #{base_dir}"
107
107
 
108
108
  get_list_of_files_for_dir(base_dir).each do |file_path|
109
- unless filePath.end_with?('.')
109
+ unless file_path.end_with?('.')
110
110
  saga_name = get_saga_name(file_path)
111
111
  load_saga(file_path, saga_name)
112
112
  end
@@ -75,7 +75,7 @@ module RServiceBus2
75
75
  end
76
76
 
77
77
  def load(path)
78
- return {} unless File.exist?(path)
78
+ return nil unless File.exist?(path)
79
79
 
80
80
  content = IO.read(path)
81
81
 
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.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Irvine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-15 00:00:00.000000000 Z
11
+ date: 2019-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuidtools