rservicebus2 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cf46f6455ed14f25642855bd4839b0c910447bb07007bdb2dba0c9a65b7f4d0
4
- data.tar.gz: 5ef71ec901e2d142d731d2dd8be176b297116ef8b6b07ab182c295496f1dfd85
3
+ metadata.gz: dd8b2dfcd1227fbfa6285ecee4096a893a6f034c9bb7106564da2423a7344c8e
4
+ data.tar.gz: de0f4dbbf5ac8f3b683485577a73f4f40d19f10705b2d487e13dbf2acd637ef4
5
5
  SHA512:
6
- metadata.gz: 35999f1a63cf911f2dc2d2d9580dc3afd26f70203db43bf7c58ee079606bb318246e292ffd382ceadfe4747d37a826a0784b3407d611c1957d61b7ea266aef05
7
- data.tar.gz: c19a66ce0e83b4c2ae617ed0e8b9827f91cf31c9820e7f0e8ba5f405f83792b097e5ed0bd9769faf331bd15c4bdfeaf9748cea40677c29e050f4f3d1d6e58815
6
+ metadata.gz: a0214102bf52760d3b773ef194cde8718ba6113637f65e4791329109b3ba3fbe05ab9b94e4f9dffc0d39d55f9e2530d5ddfd64629b9ed6916f5cf2b9ee4d38f2
7
+ data.tar.gz: 329306b143ee14af68664432dfa7d541f82ef55d1695dd16f77ebb03dd3ffbd28a7bd19f1c6a116d2220bfad302903da6569b717b36e91980bb334eb1f2773d8
@@ -33,8 +33,8 @@ module RServiceBus2
33
33
  q = queue_name
34
34
  else
35
35
  parts = queueName.split('@')
36
- msg.set_remote_queue_name(parts[0])
37
- msg.set_remote_host_name(parts[1])
36
+ msg.remote_queue_name = parts[0]
37
+ msg.remote_host_name = parts[1]
38
38
  q = 'transport-out'
39
39
  end
40
40
 
@@ -6,7 +6,7 @@ module RServiceBus2
6
6
  attr_reader :occurredat, :source_queue, :error_msg
7
7
 
8
8
  def initialize(source_queue, error_msg)
9
- @occurredat = DateTime.now
9
+ @occurredat = Time.now
10
10
 
11
11
  @source_queue = source_queue
12
12
  @error_msg = error_msg
@@ -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.set_remote_queue_name(parts[0])
343
- r_msg.set_remote_host_name(parts[1])
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)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'zlib'
2
4
  require 'yaml'
3
5
  require 'uuidtools'
@@ -5,10 +7,12 @@ 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, :remote_queue_name, :remote_host_name,
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
@@ -26,7 +30,7 @@ module RServiceBus2
26
30
  @correlation_id = correlation_id
27
31
  @return_address = return_address
28
32
 
29
- @createdat = DateTime.now
33
+ @createdat = Time.now
30
34
 
31
35
  @msg_id = UUIDTools::UUID.random_create
32
36
  @error_list = []
@@ -47,25 +51,11 @@ module RServiceBus2
47
51
  @error_list << RServiceBus2::ErrorMessage.new(source_queue, error_string)
48
52
  end
49
53
 
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
54
  # @return [Object] The msg to be sent
63
55
  def msg
64
- if @compressed == true
65
- return YAML.load(Zlib::Inflate.inflate(@_msg))
66
- else
67
- return YAML.load( @_msg )
68
- end
56
+ return YAML.load(Zlib::Inflate.inflate(@_msg)) if @compressed == true
57
+
58
+ YAML.load(@_msg)
69
59
  rescue ArgumentError => e
70
60
  raise e if e.message.index('undefined class/module ').nil?
71
61
 
@@ -124,7 +124,7 @@ module RServiceBus2
124
124
 
125
125
  unless @archivedir.nil?
126
126
  basename = File.basename(file_path)
127
- new_file_path = "#{@archivedir}/#{basename}.#{DateTime.now.strftime('%Y%m%d%H%M%S%L')}.zip"
127
+ new_file_path = "#{@archivedir}/#{basename}.#{Time.now.strftime('%Y%m%d%H%M%S%L')}.zip"
128
128
  RServiceBus2.log "Writing to archive, #{new_file_path}"
129
129
 
130
130
  Zip::ZipOutputStream.open(new_file_path) do |zos|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'beanstalk-client'
2
4
  require 'rservicebus2/mq'
3
5
 
@@ -34,6 +36,7 @@ module RServiceBus2
34
36
  abort
35
37
  end
36
38
  end
39
+ # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
37
40
 
38
41
  def subscribe(queuename)
39
42
  @beanstalk.watch(queuename)
@@ -45,6 +48,7 @@ module RServiceBus2
45
48
  @job = @beanstalk.reserve @timeout
46
49
  rescue StandardError => e
47
50
  raise NoMsgToProcess if e.message == 'TIMED_OUT'
51
+
48
52
  raise e
49
53
  end
50
54
  @job.body
@@ -63,7 +67,7 @@ module RServiceBus2
63
67
  if msg.length > @max_job_size
64
68
  puts '***Attempting to send a msg which will not fit on queue.'
65
69
  puts "***Msg size, #{msg.length}, max msg size, #{@max_job_size}."
66
- fail JobTooBigError, "Msg size, #{msg.length}, max msg size,
70
+ raise JobTooBigError, "Msg size, #{msg.length}, max msg size,
67
71
  #{@max_job_size}"
68
72
  end
69
73
  @beanstalk.use(queue_name)
@@ -5,7 +5,7 @@ module RServiceBus2
5
5
  attr_accessor :finished
6
6
 
7
7
  def initialize(saga)
8
- @createdat = DateTime.now
8
+ @createdat = Time.now
9
9
  @correlation_id = UUIDTools::UUID.random_create
10
10
  @saga_class_name = saga.class.name
11
11
  @finished = false
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rservicebus2/sendat_storage'
2
4
 
3
5
  module RServiceBus2
@@ -16,9 +18,9 @@ module RServiceBus2
16
18
  end
17
19
 
18
20
  def process
19
- now = DateTime.now
20
- @sendat_storage.get_all.each_with_index do |row, idx|
21
- next if row['timestamp'] <= now
21
+ now = Time.now
22
+ @sendat_storage.all.each_with_index do |row, idx|
23
+ next if now <= row['timestamp']
22
24
 
23
25
  @bus._send_needs_wrapping(row['msg'], row['queue_name'],
24
26
  row['correlation_id'])
@@ -1,20 +1,22 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module RServiceBus2
3
4
  # Send At Storage
4
5
  class SendAtStorage
6
+ # rubocop:disable Metrics/MethodLength
5
7
  def self.get(uri)
6
8
  case uri.scheme
7
9
  when 'file'
8
10
  require 'rservicebus2/sendat_storage/file'
9
- return SendAtStorageFile.new(uri)
11
+ SendAtStorageFile.new(uri)
10
12
  when 'inmem'
11
13
  require 'rservicebus2/sendat_storage/inmemory'
12
- return SendAtStorageInMemory.new(uri)
14
+ SendAtStorageInMemory.new(uri)
13
15
  else
14
16
  abort("Scheme, #{uri.scheme}, not recognised when configuring
15
17
  SendAtStorage, #{uri}")
16
18
  end
17
19
  end
18
-
20
+ # rubocop:enable Metrics/MethodLength
19
21
  end
20
22
  end
@@ -1,8 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RServiceBus2
2
4
  # Send at storage file
3
5
  class SendAtStorageFile
4
6
  def initialize(uri)
7
+ RServiceBus2.log "SendAtStorageFile configured: #{uri.path}"
5
8
  @list = load(uri.path)
9
+ puts "@list: #{@list.class.name}"
10
+ @path = uri.path
6
11
  end
7
12
 
8
13
  def load(path)
@@ -20,7 +25,7 @@ module RServiceBus2
20
25
  save
21
26
  end
22
27
 
23
- def get_all
28
+ def all
24
29
  @list
25
30
  end
26
31
 
@@ -31,7 +36,7 @@ module RServiceBus2
31
36
 
32
37
  def save
33
38
  content = YAML.dump(@list)
34
- File.open(@uri.path, 'w') { |f| f.write(YAML.dump(content)) }
39
+ File.open(@path, 'w') { |f| f.write(content) }
35
40
  end
36
41
  end
37
42
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RServiceBus2
2
4
  # Send at storage in memory
3
5
  class SendAtStorageInMemory
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rservicebus2/state_storage'
2
4
 
3
5
  module RServiceBus2
4
-
5
6
  # State Manager
6
7
  class StateManager
7
8
  def required
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rservicebus2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Irvine