delayed-threaded 0.17.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/delayed/fail_safe/clear_locks.rb +38 -0
- data/lib/delayed/fail_safe/clear_locks_plugin.rb +7 -0
- data/lib/delayed/threaded/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d13a30f15238ded42f550c3dc05217c02c06d675
|
4
|
+
data.tar.gz: 52577b78b63953c53e387c464cab2710b0c3cacc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa250193345448aebe7e5b075095a6c0f50bdb9ded1ea07e00d4796df454eb43e1c913c4053bba8490d23d811c2dfd2d0034a599aa81963d69f460568e60065b
|
7
|
+
data.tar.gz: 227b9f9b1960c8c3e51218018dd1de96cdaec2b1ed06a35f8661aecdb1d7edd9be7d1c93b5a72fba1c71e7f1e40e00ff68f4945cef8561c8e53e0dd69d7944af
|
data/README.md
CHANGED
@@ -55,6 +55,17 @@ the connections after work (as the worker sleeps), setup as a plugin using :
|
|
55
55
|
require 'delayed/active_record/release_connection_plugin.rb'
|
56
56
|
````
|
57
57
|
|
58
|
+
and a somehow fail-"safer" lock clearing mechanism in case of backend errors
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
# Replace DJ's default ClearLocks plugin with a fail-safe version
|
62
|
+
# e.g. when a connection goes down in the middle of job processing,
|
63
|
+
# `Delayed::Job.clear_locks!` causes a double fault to propagate.
|
64
|
+
require 'delayed/fail_safe/clear_locks_plugin.rb'
|
65
|
+
```
|
66
|
+
|
67
|
+
NOTE: **delayed_job** might not be the right tool for a fail-safe worker job.
|
68
|
+
|
58
69
|
## Development
|
59
70
|
|
60
71
|
After checking out the repo, run `bin/setup` to install dependencies.
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Delayed
|
2
|
+
module FailSafe
|
3
|
+
class ClearLocks < Plugin
|
4
|
+
|
5
|
+
@@exception_handler = lambda do |ex, worker| # fail-safe by default
|
6
|
+
worker.say "Error running clear_locks! callback: #{ex.inspect}", 'error'
|
7
|
+
end
|
8
|
+
|
9
|
+
# Allow user customizations of error handling.
|
10
|
+
#
|
11
|
+
# To get the same behavior as `Delayed::Plugins::ClearLocks` :
|
12
|
+
#
|
13
|
+
# Delayed::FailSafe::ClearLocks.exception_handler { |ex| raise(ex) }
|
14
|
+
#
|
15
|
+
def self.exception_handler(&block)
|
16
|
+
return @@exception_handler unless block_given?
|
17
|
+
@@exception_handler = block
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.call(worker)
|
21
|
+
Delayed::Job.clear_locks!(worker.name)
|
22
|
+
rescue => ex
|
23
|
+
@@exception_handler.call(ex, worker)
|
24
|
+
end
|
25
|
+
|
26
|
+
callbacks do |lifecycle|
|
27
|
+
lifecycle.around(:execute) do |worker, &block|
|
28
|
+
begin
|
29
|
+
block.call(worker)
|
30
|
+
ensure
|
31
|
+
ClearLocks.call(worker)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed-threaded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karol Bucek
|
@@ -118,6 +118,8 @@ files:
|
|
118
118
|
- delayed-threaded.gemspec
|
119
119
|
- lib/delayed/active_record/release_connection_plugin.rb
|
120
120
|
- lib/delayed/backend/active_record/release_connection.rb
|
121
|
+
- lib/delayed/fail_safe/clear_locks.rb
|
122
|
+
- lib/delayed/fail_safe/clear_locks_plugin.rb
|
121
123
|
- lib/delayed/threaded.rb
|
122
124
|
- lib/delayed/threaded/sleep_calculator.rb
|
123
125
|
- lib/delayed/threaded/sync_lifecycle.rb
|