workhorse 0.3.5 → 0.3.6

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
  SHA256:
3
- metadata.gz: 41fdd839e9d646bc4cff92ec6eda63da5ad24f4d683e9bc42ce167547247fb29
4
- data.tar.gz: 317c5da4cbd865d36d4361920f906456f4205ce3f5f09376af15aa7798347175
3
+ metadata.gz: 4a4f3666d9865ea9578e5bb735c0889a3701be869f07fc52c971777e41dbae4e
4
+ data.tar.gz: 3fca0dcf3192f1bc954c8963eb272e4aadcba4a6d2616c57600fd5ae2003a3a0
5
5
  SHA512:
6
- metadata.gz: 6e1138796a7bfae97429073564862ecd3619576ef88e28a3a043550cd054b82fac2ac79f67931080604c91e73b4356c56798d7b2801e2a9e6e8e448ea8ed31e0
7
- data.tar.gz: 5f08e73f3a4b816b59c32c902103b39e8d53d42bb8528eed02af0e73fbea576a788e24687cabb482cc652bb259fe40ee35d216f1010b48f4439aa1b52715d0dd
6
+ metadata.gz: c8437d30f0f38fee5cf2c709642af4a4a85439138ba4fbf07935a18577fdde01c1bcccdd14e84579cefee141393b878669702a835852f5ffddd9e2b39ad73699
7
+ data.tar.gz: d73c6f4432a64d9e26b1b010dc88ac5c9751cb7a7a99bce2b885e17f0b0967c540704a1d6af4a9cb4bd7e2b59dc89648a98c3de305090fa7d91ed11259c2c5aa
data/.rubocop.yml CHANGED
@@ -21,6 +21,9 @@ Style/SignalException:
21
21
  Lint/RescueWithoutErrorClass:
22
22
  Enabled: False
23
23
 
24
+ Lint/RescueException:
25
+ Enabled: False
26
+
24
27
  Style/ConditionalAssignment:
25
28
  Enabled: false
26
29
 
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Workhorse Change log
2
2
 
3
- ## 0.3.5 - unreleased
3
+ ## 0.3.6 - 2018-11-14
4
+
5
+ * Makes sure all exceptions are caught and handled properly, not only exceptions
6
+ deriving from `StandardError`. In previous releases, this prevented some
7
+ exceptions like syntax errors to be handled properly.
8
+
9
+ ## 0.3.5 - 2018-10-22
4
10
 
5
11
  * Adds global callback `on_exception` that allows custom exception handling /
6
12
  exception notification.
data/README.md CHANGED
@@ -252,7 +252,7 @@ callback of your linking, e.g.:
252
252
  Workhorse.setup do |config|
253
253
  config.on_exception = proc do |e|
254
254
  # Use gem 'exception_notification' for notifying about exceptions
255
- ExceptionNotifier.notify_exception(exception)
255
+ ExceptionNotifier.notify_exception(e)
256
256
  end
257
257
  end
258
258
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.5
1
+ 0.3.6
@@ -12,7 +12,7 @@ module Workhorse
12
12
  fail 'Performer can only run once.' if @started
13
13
  @started = true
14
14
  perform!
15
- rescue => e
15
+ rescue Exception => e
16
16
  Workhorse.on_exception.call(e)
17
17
  end
18
18
 
@@ -30,7 +30,7 @@ module Workhorse
30
30
  perform_wrapped
31
31
  end
32
32
  end
33
- rescue => e
33
+ rescue Exception => e
34
34
  # ---------------------------------------------------------------
35
35
  # Mark job as failed
36
36
  # ---------------------------------------------------------------
@@ -25,7 +25,7 @@ module Workhorse
25
25
  poll
26
26
  sleep
27
27
  end
28
- rescue => e
28
+ rescue Exception => e
29
29
  worker.log %(Poller stopped with exception:\n#{e.message}\n#{e.backtrace.join("\n")})
30
30
  end
31
31
  end
@@ -129,12 +129,12 @@ module Workhorse
129
129
  @pool.post do
130
130
  begin
131
131
  Workhorse::Performer.new(db_job, self).perform
132
- rescue => e
132
+ rescue Exception => e
133
133
  log %(#{e.message}\n#{e.backtrace.join("\n")}), :error
134
134
  end
135
135
  end
136
136
  end
137
- rescue => e
137
+ rescue Exception => e
138
138
  Workhorse.on_exception.call(e)
139
139
  end
140
140
 
data/test/lib/jobs.rb CHANGED
@@ -30,6 +30,12 @@ class FailingTestJob
30
30
  end
31
31
  end
32
32
 
33
+ class SyntaxErrorJob
34
+ def perform
35
+ fail SyntaxError
36
+ end
37
+ end
38
+
33
39
  class DummyRailsOpsOp
34
40
  class_attribute :results
35
41
  self.results = Concurrent::Array.new
@@ -14,6 +14,24 @@ class Workhorse::WorkerTest < WorkhorseTest
14
14
  assert_equal 2, DbConnectionTestJob.db_connections.uniq.count
15
15
  end
16
16
 
17
+ def test_success
18
+ Workhorse.enqueue BasicJob.new(sleep_time: 0.1)
19
+ work 0.2, polling_interval: 0.2
20
+ assert_equal 'succeeded', Workhorse::DbJob.first.state
21
+ end
22
+
23
+ def test_exception
24
+ Workhorse.enqueue FailingTestJob
25
+ work 0.2, polling_interval: 0.2
26
+ assert_equal 'failed', Workhorse::DbJob.first.state
27
+ end
28
+
29
+ def test_syntax_exception
30
+ Workhorse.enqueue SyntaxErrorJob
31
+ work 0.2, polling_interval: 0.2
32
+ assert_equal 'failed', Workhorse::DbJob.first.state
33
+ end
34
+
17
35
  def test_on_exception
18
36
  old_callback = Workhorse.on_exception
19
37
  exception = nil
data/workhorse.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: workhorse 0.3.5 ruby lib
2
+ # stub: workhorse 0.3.6 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "workhorse".freeze
6
- s.version = "0.3.5"
6
+ s.version = "0.3.6"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Sitrox".freeze]
11
- s.date = "2018-10-22"
11
+ s.date = "2018-11-14"
12
12
  s.files = [".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".travis.yml".freeze, "CHANGELOG.md".freeze, "FAQ.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rubocop".freeze, "lib/generators/workhorse/install_generator.rb".freeze, "lib/generators/workhorse/templates/bin/workhorse.rb".freeze, "lib/generators/workhorse/templates/config/initializers/workhorse.rb".freeze, "lib/generators/workhorse/templates/create_table_jobs.rb".freeze, "lib/workhorse.rb".freeze, "lib/workhorse/daemon.rb".freeze, "lib/workhorse/daemon/shell_handler.rb".freeze, "lib/workhorse/db_job.rb".freeze, "lib/workhorse/enqueuer.rb".freeze, "lib/workhorse/jobs/cleanup_succeeded_jobs.rb".freeze, "lib/workhorse/jobs/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze, "workhorse.gemspec".freeze]
13
13
  s.rubygems_version = "2.7.6".freeze
14
14
  s.summary = "Multi-threaded job backend with database queuing for ruby.".freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workhorse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-22 00:00:00.000000000 Z
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler