dispatch-rider 1.3.0 → 1.3.1

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: e5b012324043e834bb969b954be7155db10dfef3
4
- data.tar.gz: 518a531a1b759c8ec46c23f86fd00ca49c9a4f24
3
+ metadata.gz: 8f3c1d68135996d3628b82282bbed5c3675f65b6
4
+ data.tar.gz: e4ac7f3fba37caf912d6234f46c6b6d4a7ce844c
5
5
  SHA512:
6
- metadata.gz: 88725c8098ff777bf56e7db51652604cf1b32142a8816b74842c614be79133d3233851d0057d74c9ea1805d6b283d0d9d432488271a2aceb9fb9a380f964baeb
7
- data.tar.gz: f5374cb26723f85e00c9041e82c7c9d718a1b535ba32894fb70bf30b192a11673bcc4ac1b95aff04a0c08f4a77148f23223ee5aa2d36eb13f87e0df4b0d4876b
6
+ metadata.gz: 2f033db5fe1c3eae2ab79a4c788d361274bf15a7ce70343377497843232a0167a744d704d2beda5016452f5911dfd82a1ff1dba4998e6f683cbb1ecb2f8e5300
7
+ data.tar.gz: 4bfc2d394353d7dbef8688000a2a2d6e752aeba7fa06e445e6e9ea176100db9044528c55856036a49547c25ea46d30e266ece6c6fa555d50a3c6d921ba1e9eb6
@@ -24,7 +24,6 @@ module DispatchRider
24
24
  end
25
25
 
26
26
  require "dispatch-rider/debug"
27
- require "dispatch-rider/signal_tools"
28
27
  require "dispatch-rider/errors"
29
28
  require "dispatch-rider/error_handlers"
30
29
  require "dispatch-rider/handlers"
@@ -13,7 +13,6 @@ module DispatchRider
13
13
  @error_handler = error_handler
14
14
  @continue = true
15
15
  @current_message = nil
16
- install_term_trap
17
16
  end
18
17
 
19
18
  def start
@@ -28,23 +27,22 @@ module DispatchRider
28
27
  self
29
28
  end
30
29
 
31
- def stop
30
+ def stop(reason: nil)
32
31
  @continue = false
32
+ if @current_message
33
+ logger.info "Got stop #{reason ? '(' + reason + ') ' : ' ' }while executing: #{message_info_fragment(@current_message)}"
34
+ end
33
35
  end
34
36
 
35
37
  private
36
38
 
37
- def install_term_trap
38
- SignalTools.append_trap('TERM') do
39
- logger.info "Got SIGTERM while executing: #{message_info_fragment(@current_message)}" if @current_message
40
- end
41
- end
42
-
43
39
  def with_current_message(message)
44
- @current_message = message
45
- result = yield
46
- @current_message = nil
47
- result
40
+ begin
41
+ @current_message = message
42
+ yield
43
+ ensure
44
+ @current_message = nil
45
+ end
48
46
  end
49
47
 
50
48
  # This needs to return true/false based on the success of the jobs!
@@ -40,30 +40,30 @@ module DispatchRider
40
40
  private
41
41
 
42
42
  def register_quit_trap
43
- SignalTools.append_trap("QUIT") do
43
+ Signal.trap("QUIT") do
44
44
  # signal number: 3
45
45
  logger.info "Received SIGQUIT, stopping demultiplexer"
46
- demultiplexer.stop
46
+ demultiplexer.stop("Got SIGQUIT")
47
47
  end
48
48
  end
49
49
 
50
50
  def register_term_trap
51
- SignalTools.append_trap("TERM") do
51
+ Signal.trap("TERM") do
52
52
  # signal number: 15
53
53
  logger.info "Received SIGTERM, stopping demultiplexer"
54
- demultiplexer.stop
54
+ demultiplexer.stop("Got SIGTERM")
55
55
  end
56
56
  end
57
57
 
58
58
  def register_int_trap
59
59
  @already_interrupted = false
60
- SignalTools.append_trap("INT") do
60
+ Signal.trap("INT") do
61
61
  if @already_interrupted
62
62
  logger.info "Received SIGINT second time, aborting"
63
63
  exit(0)
64
64
  else
65
65
  logger.info "Received SIGINT first time, stopping demultiplexer"
66
- demultiplexer.stop
66
+ demultiplexer.stop("Got SIGINT")
67
67
  end
68
68
  @already_interrupted = true
69
69
  end
@@ -1,4 +1,4 @@
1
1
  # This file specifies the current version of the gem.
2
2
  module DispatchRider
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dispatch-rider
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suman Mukherjee
@@ -203,7 +203,6 @@ files:
203
203
  - lib/dispatch-rider/registrars/queue_service.rb
204
204
  - lib/dispatch-rider/registrars/sns_channel.rb
205
205
  - lib/dispatch-rider/runner.rb
206
- - lib/dispatch-rider/signal_tools.rb
207
206
  - lib/dispatch-rider/subscriber.rb
208
207
  - lib/dispatch-rider/version.rb
209
208
  - lib/generators/dispatch_rider/install/USAGE
@@ -1,8 +0,0 @@
1
- module SignalTools
2
- def self.append_trap(signal, &block)
3
- old_handler = trap(signal) do
4
- block.call
5
- old_handler.call if old_handler.respond_to?(:call)
6
- end
7
- end
8
- end