servitude 1.0.0 → 1.1.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: 3bc5c02aa6f0759b2c023219955399164bc1fb7f
4
- data.tar.gz: ed9b38cdedb0f0a593619abd71ae5e23ceb0a351
3
+ metadata.gz: dce6d48e55e0ea709cbac0ab8bb83576f5d4f855
4
+ data.tar.gz: c96667392283ea694bd05cdccbfe48a054a40416
5
5
  SHA512:
6
- metadata.gz: 9aed8c3cfb27f402763f0cbb60291d4c8d3f46c4b8afe4ad76860812210071f60e8a74a25101925c5d8f2e8922e159b666703c2b695bc4237924f20d3caf7916
7
- data.tar.gz: 0722743586090901fbe060ee76f26efe40540e89fd7795b10ea2459eb319eac8bbcc872a5deebbd611a6905ac5914501039e4ffd7784078d15cfe56ad69f90b8
6
+ metadata.gz: b79ae5973d8b1788a8ff27956081e746bc61bd91f53bab9bd5f509d04994950dd395883a0e87aa8c80b2ce256301805c65632000dfeaa859927d31e16a736a4a
7
+ data.tar.gz: f0946a59b22f543d219a45c3286ea3c93d6e26ae77080399c10faf137285b9ac231cb726200c64d71a4344fac8decc2fb6c83caeb07f0dd6c5c5a4e8b3c9b470
@@ -1,9 +1,12 @@
1
+ require 'celluloid'
2
+
1
3
  module Servitude
2
4
  module ServerThreaded
3
5
 
4
6
  def self.included( base )
5
7
  base.class_eval do
6
8
  after_initialize :initialize_thread
9
+ after_initialize :initialize_celluloid_logger
7
10
  end
8
11
  end
9
12
 
@@ -17,21 +20,29 @@ module Servitude
17
20
  raise NotImplementedError
18
21
  end
19
22
 
20
- def with_supervision( &block )
23
+ def with_supervision( options={}, &block )
21
24
  begin
22
25
  block.call
23
26
  rescue Servitude::SupervisionError
24
27
  # supervisor is restarting actor
25
28
  warn_for_supevision_error
26
- sleep( config.supervision_retry_timeout || 0 )
29
+ notify_and_sleep_if_configured
27
30
  retry
28
31
  rescue Celluloid::DeadActorError
29
32
  # supervisor has yet to begin restarting actor
30
33
  warn_for_dead_actor_error
31
- sleep( config.supervision_retry_timeout || 0 )
34
+ notify_and_sleep_if_configured
32
35
  retry
33
36
  rescue => e
34
- handle_error( payload, delivery_info, e )
37
+ handle_error( options, e )
38
+ end
39
+ end
40
+
41
+ def notify_and_sleep_if_configured
42
+ if config.supervision_retry_timeout_in_seconds &&
43
+ config.supervision_retry_timeout_in_seconds > 0
44
+ debug "Sleeping for #{config.supervision_retry_timeout_in_seconds}s ..."
45
+ sleep( config.supervision_retry_timeout_in_seconds )
35
46
  end
36
47
  end
37
48
 
@@ -43,8 +54,13 @@ module Servitude
43
54
  warn "RETRYING due to Celluloid::DeadActorError ..."
44
55
  end
45
56
 
46
- def handle_error( payload, delivery_info, e )
47
- error( "#{e.class.name} | #{e.message} | #{e.backtrace.inspect}" )
57
+ def handle_error( options, e )
58
+ parts = [[e.class.name, e.message].join( ' ' ), format_backtrace( e.backtrace )]
59
+ error( parts.join( "\n" ))
60
+ end
61
+
62
+ def format_backtrace( backtrace )
63
+ " #{backtrace.join "\n "}"
48
64
  end
49
65
 
50
66
  # Correctly calls a single supervised actor when the threads configuraiton is set
@@ -69,6 +85,10 @@ module Servitude
69
85
  Celluloid::Actor[:handler]
70
86
  end
71
87
 
88
+ def initialize_celluloid_logger
89
+ Celluloid.logger = nil
90
+ end
91
+
72
92
  def initialize_thread
73
93
  return unless config.threads == 1
74
94
  handler_class.supervise_as :handler
@@ -1,3 +1,3 @@
1
1
  module Servitude
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servitude
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Harrelson