psyho-stalker 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -72,7 +72,7 @@ Error Handling
72
72
 
73
73
  If you include an `error` block in your jobs definition, that block will be invoked when a worker encounters an error. You might use this to report errors to an external monitoring service:
74
74
 
75
- error do |job_name, args, e|
75
+ error do |e, job_name, args|
76
76
  Exceptional.handle(e)
77
77
  end
78
78
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
data/lib/stalker.rb CHANGED
@@ -96,7 +96,13 @@ module Stalker
96
96
  log_error exception_message(e)
97
97
  job.bury rescue nil
98
98
  log_job_end(name, 'failed')
99
- error_handler.call(name, args, e) if error_handler
99
+ if error_handler
100
+ if error_handler.arity == 1
101
+ error_handler.call(e)
102
+ else
103
+ error_handler.call(e, name, args)
104
+ end
105
+ end
100
106
  end
101
107
 
102
108
  def failed_connection(e)
data/test/stalker_test.rb CHANGED
@@ -15,7 +15,7 @@ class StalkerTest < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def with_an_error_handler
18
- Stalker.error do |job_name, args, e|
18
+ Stalker.error do |e, job_name, args|
19
19
  $handled = e.class
20
20
  $job_name = job_name
21
21
  $job_args = args
@@ -42,6 +42,16 @@ class StalkerTest < Test::Unit::TestCase
42
42
  assert_equal({'foo' => 123}, $job_args)
43
43
  end
44
44
 
45
+ test "should be compatible with legacy error handlers" do
46
+ exception = StandardError.new("Oh my, the job has failed!")
47
+ Stalker.error { |e| $handled = e }
48
+ Stalker.job('my.job') { |args| raise exception }
49
+ Stalker.enqueue('my.job', :foo => 123)
50
+ Stalker.prep
51
+ Stalker.work_one_job
52
+ assert_equal exception, $handled
53
+ end
54
+
45
55
  test "continue working when error handler not defined" do
46
56
  Stalker.job('my.job') { fail }
47
57
  Stalker.enqueue('my.job')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psyho-stalker
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 0
10
- version: 0.7.0
9
+ - 1
10
+ version: 0.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adam Wiggins
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-16 00:00:00 +01:00
18
+ date: 2011-02-23 00:00:00 +01:00
19
19
  default_executable: stalk
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency