freekiqs 5.0.0 → 6.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/Procfile +1 -0
- data/README.md +16 -23
- data/development/redis/redis.conf +49 -0
- data/freekiqs.gemspec +2 -2
- data/lib/sidekiq/middleware/server/freekiqs.rb +4 -4
- data/shell.nix +42 -0
- data/spec/freekiqs_spec.rb +3 -2
- data/spec/spec_helper.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d6b06dcd42bf69b36943cb98073500edaa179251c807284ac1520788f4f9b868
|
4
|
+
data.tar.gz: 7d273e8393c7f4ec61b2bc3488daaa3a8e7c4d2c3c4e323d0787f3217a1ec772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beeb49dbe17a46885ab99ff7c2128645fb739496a7636a2a0b8f041c7b1099dfd42e291f23d15bf49b0ff4b1da09d01da8a8f8d2cb9ed482db09982143d64d65
|
7
|
+
data.tar.gz: 1ce3a30d1d569967f3c0b3fe6941baf00cfaa6c99da09436e87481b29e8dfa1412cef2ede6853ae4c9e6099aa547149b01c943ac613891cb7b39d0020c7b44e1
|
data/.gitignore
CHANGED
data/Procfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
redis: redis-server development/redis/redis.conf --bind $HOST
|
data/README.md
CHANGED
@@ -5,6 +5,21 @@ by failed jobs and wrapping them with a `FreekiqException` exception class
|
|
5
5
|
that can be filtered by monitoring tools such as New Relic and
|
6
6
|
Rollbar.
|
7
7
|
|
8
|
+
#### Implementation Details
|
9
|
+
|
10
|
+
This relies on Sidekiq's built-in retry handling. Specifically, its
|
11
|
+
`retry_count` value. When a job first fails, its `retry_count` value
|
12
|
+
is nil (because it hasn't actually been retried yet). That exception,
|
13
|
+
along with subsequent exceptions from retries, are caught and wrapped
|
14
|
+
with the `FreekiqException` exception.
|
15
|
+
Cases where Freekiqs does NOT wrap the exception:
|
16
|
+
- The `retry` option is false
|
17
|
+
- The `freekiqs` option is not set on the worker nor globally
|
18
|
+
- The `freekiqs` option is not set on worker and set to `false` globally
|
19
|
+
- The `freekiqs` option is set to `false` on the worker
|
20
|
+
- The job threw an exception that is not a StandardError (nor a subclass)
|
21
|
+
- The number of thrown exceptions is more than specified freekiqs
|
22
|
+
|
8
23
|
Configuration example (in config/initializers/sidekiq.rb):
|
9
24
|
``` ruby
|
10
25
|
Sidekiq.configure_server do |config|
|
@@ -101,26 +116,4 @@ If MyWorker throws a SubMyError or MyError, it will get freekiq'd.
|
|
101
116
|
Version 5 of this gem only works with Sidekiq 5 and higher. If you are using
|
102
117
|
an older version of Sidekiq, you'll need to use version [4.1.0](https://github.com/BookBub/freekiqs/tree/v4.1.0).
|
103
118
|
|
104
|
-
|
105
|
-
|
106
|
-
Up to the configured number of "freekiqs", catch exceptions thrown
|
107
|
-
from job and wrap them with the `FreekiqException` exception (which is a
|
108
|
-
`RuntimeError`). That exception type can be ignored by monitoring
|
109
|
-
tools. If job fails more times than configured "freekiqs", thrown
|
110
|
-
exception will not be wrapped. That should result in normal operation
|
111
|
-
and the exception showing up in monitoring tools.
|
112
|
-
|
113
|
-
#### Implementation Details
|
114
|
-
|
115
|
-
This relies on Sidekiq's built-in retry handling. Specifically, its
|
116
|
-
`retry_count` value. When a job first fails, its `retry_count` value
|
117
|
-
is nil (because it hasn't actually been retried yet). That exception,
|
118
|
-
along with subsequent exceptions from retries, are caught and wrapped
|
119
|
-
with the `FreekiqException` exception.
|
120
|
-
Cases where Freekiqs does NOT wrap the exception:
|
121
|
-
- The `retry` option is false
|
122
|
-
- The `freekiqs` option is not set on the worker nor globally
|
123
|
-
- The `freekiqs` option is not set on worker and set to `false` globally
|
124
|
-
- The `freekiqs` option is set to `false` on the worker
|
125
|
-
- The job threw an exception that is not a StandardError (nor a subclass)
|
126
|
-
- The number of thrown exceptions is more than specified freekiqs
|
119
|
+
Version 6.5.0 of this gem works with Sidekiq 6.5 and higher.
|
@@ -0,0 +1,49 @@
|
|
1
|
+
protected-mode yes
|
2
|
+
port 6379
|
3
|
+
tcp-backlog 511
|
4
|
+
timeout 0
|
5
|
+
tcp-keepalive 300
|
6
|
+
daemonize no
|
7
|
+
supervised no
|
8
|
+
pidfile development/redis/redis_6379.pid
|
9
|
+
loglevel warning
|
10
|
+
logfile ""
|
11
|
+
databases 16
|
12
|
+
save 900 1
|
13
|
+
save 300 10
|
14
|
+
save 60 10000
|
15
|
+
stop-writes-on-bgsave-error yes
|
16
|
+
rdbcompression yes
|
17
|
+
rdbchecksum yes
|
18
|
+
dbfilename dump.rdb
|
19
|
+
dir development/redis
|
20
|
+
slave-serve-stale-data yes
|
21
|
+
slave-read-only yes
|
22
|
+
repl-diskless-sync no
|
23
|
+
repl-diskless-sync-delay 5
|
24
|
+
repl-disable-tcp-nodelay no
|
25
|
+
slave-priority 100
|
26
|
+
appendonly no
|
27
|
+
appendfilename "appendonly.aof"
|
28
|
+
appendfsync no
|
29
|
+
no-appendfsync-on-rewrite no
|
30
|
+
auto-aof-rewrite-percentage 100
|
31
|
+
auto-aof-rewrite-min-size 64mb
|
32
|
+
aof-load-truncated yes
|
33
|
+
lua-time-limit 5000
|
34
|
+
latency-monitor-threshold 0
|
35
|
+
notify-keyspace-events ""
|
36
|
+
hash-max-ziplist-entries 512
|
37
|
+
hash-max-ziplist-value 64
|
38
|
+
list-max-ziplist-size -2
|
39
|
+
list-compress-depth 0
|
40
|
+
set-max-intset-entries 512
|
41
|
+
zset-max-ziplist-entries 128
|
42
|
+
zset-max-ziplist-value 64
|
43
|
+
hll-sparse-max-bytes 3000
|
44
|
+
activerehashing yes
|
45
|
+
client-output-buffer-limit normal 0 0 0
|
46
|
+
client-output-buffer-limit slave 256mb 64mb 60
|
47
|
+
client-output-buffer-limit pubsub 32mb 8mb 60
|
48
|
+
hz 10
|
49
|
+
aof-rewrite-incremental-fsync yes
|
data/freekiqs.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'freekiqs'
|
5
|
-
gem.version = '5.0
|
5
|
+
gem.version = '6.5.0'
|
6
6
|
gem.authors = ['Rob Lewis']
|
7
7
|
gem.email = ['rob@bookbub.com']
|
8
8
|
gem.summary = 'Sidekiq middleware extending RetryJobs to allow silient errors.'
|
@@ -16,6 +16,6 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ['lib']
|
17
17
|
gem.required_ruby_version = '>= 2.2.2'
|
18
18
|
|
19
|
-
gem.add_dependency 'sidekiq', '>= 5.0
|
19
|
+
gem.add_dependency 'sidekiq', '>= 6.5.0'
|
20
20
|
gem.add_development_dependency 'rspec', '>= 3.6.0'
|
21
21
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'sidekiq'
|
2
|
-
require 'sidekiq/
|
2
|
+
require 'sidekiq/middleware/modules'
|
3
3
|
|
4
4
|
module Sidekiq
|
5
5
|
class FreekiqException < RuntimeError; end
|
@@ -7,7 +7,7 @@ module Sidekiq
|
|
7
7
|
module Middleware
|
8
8
|
module Server
|
9
9
|
class Freekiqs
|
10
|
-
include Sidekiq::
|
10
|
+
include Sidekiq::ServerMiddleware
|
11
11
|
@@callback = nil
|
12
12
|
|
13
13
|
def initialize(opts={})
|
@@ -25,12 +25,12 @@ module Sidekiq
|
|
25
25
|
begin
|
26
26
|
@@callback.call(worker, msg, queue) if @@callback
|
27
27
|
rescue => callback_exception
|
28
|
-
|
28
|
+
logger.info { "Freekiq callback failed for #{msg['class']} job #{msg['jid']}" }
|
29
29
|
ensure
|
30
30
|
raise FreekiqException, ex.message
|
31
31
|
end
|
32
32
|
else
|
33
|
-
|
33
|
+
logger.info { "Out of freekiqs for #{msg['class']} job #{msg['jid']}" }
|
34
34
|
end
|
35
35
|
end
|
36
36
|
raise ex
|
data/shell.nix
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
{ system ? builtins.currentSystem }:
|
2
|
+
|
3
|
+
with (import (fetchTarball {
|
4
|
+
name = "nixpkgs-21.11";
|
5
|
+
url = "https://github.com/nixos/nixpkgs/archive/21.11.tar.gz";
|
6
|
+
sha256 = "162dywda2dvfj1248afxc45kcrg83appjd0nmdb541hl7rnncf02";
|
7
|
+
}) { inherit system; });
|
8
|
+
|
9
|
+
|
10
|
+
let
|
11
|
+
requiredNixVersion = "2.3";
|
12
|
+
|
13
|
+
pwd = builtins.getEnv "PWD";
|
14
|
+
in
|
15
|
+
|
16
|
+
if lib.versionOlder builtins.nixVersion requiredNixVersion == true then
|
17
|
+
abort "This project requires Nix >= ${requiredNixVersion}, please run 'nix-channel --update && nix-env -i nix'."
|
18
|
+
else
|
19
|
+
|
20
|
+
mkShell {
|
21
|
+
buildInputs = [
|
22
|
+
stdenv
|
23
|
+
git
|
24
|
+
cacert
|
25
|
+
|
26
|
+
# Ruby and Rails dependencies
|
27
|
+
ruby_2_7.devEnv
|
28
|
+
bundler
|
29
|
+
|
30
|
+
# Services
|
31
|
+
overmind
|
32
|
+
redis
|
33
|
+
|
34
|
+
] ++ lib.optional (!stdenv.isDarwin) [
|
35
|
+
# linux-only packages
|
36
|
+
glibcLocales
|
37
|
+
];
|
38
|
+
|
39
|
+
HOST = "127.0.0.24";
|
40
|
+
REDIS_URL="redis://127.0.0.24:6379/1";
|
41
|
+
BUNDLE_PATH = "vendor/bundle";
|
42
|
+
}
|
data/spec/freekiqs_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'sidekiq'
|
2
|
+
require 'sidekiq/api'
|
1
3
|
require 'sidekiq/processor'
|
2
4
|
|
3
5
|
RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
@@ -15,8 +17,7 @@ RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def process_job(job_hash)
|
18
|
-
|
19
|
-
processor = ::Sidekiq::Processor.new(mgr)
|
20
|
+
processor = Sidekiq::Processor.new(Sidekiq)
|
20
21
|
job_msg = Sidekiq.dump_json(job_hash)
|
21
22
|
processor.process(Sidekiq::BasicFetch::UnitOfWork.new('queue:default', job_msg))
|
22
23
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freekiqs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0
|
4
|
+
version: 6.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Lewis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.0
|
19
|
+
version: 6.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.0
|
26
|
+
version: 6.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,13 +50,16 @@ files:
|
|
50
50
|
- ".rspec"
|
51
51
|
- Gemfile
|
52
52
|
- MIT-LICENSE
|
53
|
+
- Procfile
|
53
54
|
- README.md
|
54
55
|
- Rakefile
|
55
56
|
- Vagrantfile
|
56
57
|
- circle.yml
|
58
|
+
- development/redis/redis.conf
|
57
59
|
- freekiqs.gemspec
|
58
60
|
- lib/freekiqs.rb
|
59
61
|
- lib/sidekiq/middleware/server/freekiqs.rb
|
62
|
+
- shell.nix
|
60
63
|
- spec/freekiqs_spec.rb
|
61
64
|
- spec/spec_helper.rb
|
62
65
|
homepage: https://github.com/BookBub/freekiqs
|
@@ -78,8 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
81
|
- !ruby/object:Gem::Version
|
79
82
|
version: '0'
|
80
83
|
requirements: []
|
81
|
-
|
82
|
-
rubygems_version: 2.6.11
|
84
|
+
rubygems_version: 3.0.3.1
|
83
85
|
signing_key:
|
84
86
|
specification_version: 4
|
85
87
|
summary: Sidekiq middleware extending RetryJobs to allow silient errors.
|