freekiqs 5.0.0 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- data/.github/workflows/test.yml +29 -0
- data/.gitignore +6 -3
- data/Appraisals +7 -0
- data/CHANGELOG.md +46 -0
- data/Gemfile.lock +56 -0
- data/Procfile +1 -0
- data/README.md +16 -23
- data/development/redis/redis.conf +49 -0
- data/flake.lock +27 -0
- data/flake.nix +34 -0
- data/freekiqs.gemspec +3 -2
- data/gemfiles/sidekiq_7.gemfile +12 -0
- data/gemfiles/sidekiq_7.gemfile.lock +57 -0
- data/gemfiles/sidekiq_8.gemfile +12 -0
- data/gemfiles/sidekiq_8.gemfile.lock +57 -0
- data/lib/sidekiq/middleware/server/freekiqs.rb +4 -4
- data/spec/freekiqs_spec.rb +103 -80
- data/spec/spec_helper.rb +3 -1
- metadata +32 -11
- data/Vagrantfile +0 -31
- data/circle.yml +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 64914c0a481a3e2337d05eec0d6f094e523c6c77aef42b4d44f7a8ed4cc24d9f
|
|
4
|
+
data.tar.gz: 97a56d9f74649236d2dd2f640a0bcd34ce7c54ca01386d96b62c932629113fe8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43d753115648d1d004f34cea277e27b3fe8d1ab013485b069f88a8c68949ba4ee964f88e6e6d10b43b1829f86c0de5e924dcdd7b10bd4899e3c5ce5407669cb2
|
|
7
|
+
data.tar.gz: 06751ee75a308d1be8e72aa8487ceeb0ab7a3f58620268cef095b4503033b551fd3d67e020df0acb91f89ec17577c79dace1d26c6d492e000cf9a4048f2eb4cc
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
### Why is this change necessary?
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### How does this change address the issue?
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### What side effects does this change have?
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### General TODOs
|
|
11
|
+
- [ ] Test in at least one app to make sure that there are no breaking changes
|
|
12
|
+
- [ ] Notify consuming apps of breaking changes
|
|
13
|
+
- [ ] Ensure the updates is backwards compatible
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
ruby: ["3.2", "3.3", "3.4", "4.0"]
|
|
15
|
+
gemfile: [sidekiq_7, sidekiq_8]
|
|
16
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
|
|
17
|
+
env:
|
|
18
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- name: Set up Ruby
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
bundler-cache: true
|
|
25
|
+
ruby-version: ${{ matrix.ruby }}
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: bundle install
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/Appraisals
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [6.6.0] - 2026-08-10
|
|
6
|
+
|
|
7
|
+
* Support Sidekiq 8 (#19)
|
|
8
|
+
* Introduce the appraisal gem so the suite runs against multiple Sidekiq versions (#18)
|
|
9
|
+
* Test against Sidekiq 7 (#10)
|
|
10
|
+
* Test against Ruby 3.2, 3.3 and 3.4 (#17), dropping support for Ruby 3.1 (#15)
|
|
11
|
+
* Test using Sidekiq's fake testing mode (#12)
|
|
12
|
+
* Change logger setup (#9)
|
|
13
|
+
* Move CI from CircleCI to GitHub Actions (#11)
|
|
14
|
+
* Check in `Gemfile.lock` (#16)
|
|
15
|
+
* Migrate from `shell.nix` to `flake.nix`, upgrading to nixpkgs 26.05 and ruby 4.0
|
|
16
|
+
* Add ruby 4.0 to the CI matrix
|
|
17
|
+
* Update dependent gems and drop stale entries from the lockfile's platform list
|
|
18
|
+
* Drop the unused `Vagrantfile`
|
|
19
|
+
|
|
20
|
+
## [6.5.0] - 2022-10-11
|
|
21
|
+
|
|
22
|
+
* Support Sidekiq 6.5 and higher (#7)
|
|
23
|
+
* Rails 5 compatibility (#6)
|
|
24
|
+
|
|
25
|
+
## [5.0.0] - 2017-08-03
|
|
26
|
+
|
|
27
|
+
* Update to work with Sidekiq v5+
|
|
28
|
+
|
|
29
|
+
## [4.1.0] - 2016-06-24
|
|
30
|
+
|
|
31
|
+
* Add a `freekiq_for` option, letting specific errors be defined as the only errors that will
|
|
32
|
+
freekiq (#5)
|
|
33
|
+
|
|
34
|
+
## [4.0.0] - 2016-06-21
|
|
35
|
+
|
|
36
|
+
* Allow Sidekiq v4
|
|
37
|
+
* Switch `sidekiq_options` to use the getter, `get_sidekiq_options` (#3)
|
|
38
|
+
|
|
39
|
+
## [0.2.0] - 2016-01-26
|
|
40
|
+
|
|
41
|
+
* Add an optional callback for each freekiq (#1)
|
|
42
|
+
* Relax the version dependency for rspec
|
|
43
|
+
|
|
44
|
+
## [0.1.0] - 2016-01-26
|
|
45
|
+
|
|
46
|
+
* Initial release
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
freekiqs (6.6.0)
|
|
5
|
+
sidekiq (>= 6.5.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
appraisal (2.5.0)
|
|
11
|
+
bundler
|
|
12
|
+
rake
|
|
13
|
+
thor (>= 0.14.0)
|
|
14
|
+
connection_pool (3.0.2)
|
|
15
|
+
diff-lcs (1.6.2)
|
|
16
|
+
json (2.21.2)
|
|
17
|
+
logger (1.7.0)
|
|
18
|
+
rack (3.2.6)
|
|
19
|
+
rake (13.4.2)
|
|
20
|
+
redis-client (0.30.1)
|
|
21
|
+
connection_pool
|
|
22
|
+
rspec (3.13.2)
|
|
23
|
+
rspec-core (~> 3.13.0)
|
|
24
|
+
rspec-expectations (~> 3.13.0)
|
|
25
|
+
rspec-mocks (~> 3.13.0)
|
|
26
|
+
rspec-core (3.13.6)
|
|
27
|
+
rspec-support (~> 3.13.0)
|
|
28
|
+
rspec-expectations (3.13.5)
|
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
30
|
+
rspec-support (~> 3.13.0)
|
|
31
|
+
rspec-mocks (3.13.8)
|
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
33
|
+
rspec-support (~> 3.13.0)
|
|
34
|
+
rspec-support (3.13.7)
|
|
35
|
+
sidekiq (8.1.6)
|
|
36
|
+
connection_pool (>= 3.0.0)
|
|
37
|
+
json (>= 2.16.0)
|
|
38
|
+
logger (>= 1.7.0)
|
|
39
|
+
rack (>= 3.2.0)
|
|
40
|
+
redis-client (>= 0.29.0)
|
|
41
|
+
thor (1.5.0)
|
|
42
|
+
|
|
43
|
+
PLATFORMS
|
|
44
|
+
aarch64-linux
|
|
45
|
+
arm64-darwin
|
|
46
|
+
ruby
|
|
47
|
+
x86_64-linux
|
|
48
|
+
|
|
49
|
+
DEPENDENCIES
|
|
50
|
+
appraisal
|
|
51
|
+
freekiqs!
|
|
52
|
+
rake
|
|
53
|
+
rspec (~> 3.6, >= 3.6.0)
|
|
54
|
+
|
|
55
|
+
BUNDLED WITH
|
|
56
|
+
4.0.10
|
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. Last tested with Sidekiq 8.1.3.
|
|
@@ -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/flake.lock
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodes": {
|
|
3
|
+
"nixpkgs": {
|
|
4
|
+
"locked": {
|
|
5
|
+
"lastModified": 1786313170,
|
|
6
|
+
"narHash": "sha256-9BG7OgUWdu0ONDO5X2q6+K4bsuBITkX/3W4nNJu1Ito=",
|
|
7
|
+
"owner": "NixOS",
|
|
8
|
+
"repo": "nixpkgs",
|
|
9
|
+
"rev": "fcb8fcd6bf2d0adecae5bd491afaaaf8311b758d",
|
|
10
|
+
"type": "github"
|
|
11
|
+
},
|
|
12
|
+
"original": {
|
|
13
|
+
"owner": "NixOS",
|
|
14
|
+
"ref": "nixos-26.05",
|
|
15
|
+
"repo": "nixpkgs",
|
|
16
|
+
"type": "github"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"root": {
|
|
20
|
+
"inputs": {
|
|
21
|
+
"nixpkgs": "nixpkgs"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"root": "root",
|
|
26
|
+
"version": 7
|
|
27
|
+
}
|
data/flake.nix
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
description = "Sidekiq middleware extending RetryJobs to allow silent errors";
|
|
3
|
+
|
|
4
|
+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
|
5
|
+
|
|
6
|
+
outputs = { self, nixpkgs }:
|
|
7
|
+
let
|
|
8
|
+
supportedSystems = [ "aarch64-darwin" "aarch64-linux" "x86_64-linux" ];
|
|
9
|
+
forAllSystems = f:
|
|
10
|
+
nixpkgs.lib.genAttrs supportedSystems (system: f nixpkgs.legacyPackages.${system});
|
|
11
|
+
host = "127.0.0.24";
|
|
12
|
+
in
|
|
13
|
+
{
|
|
14
|
+
devShells = forAllSystems (pkgs: {
|
|
15
|
+
default = pkgs.mkShell {
|
|
16
|
+
buildInputs = with pkgs; [
|
|
17
|
+
git
|
|
18
|
+
cacert
|
|
19
|
+
ruby_4_0
|
|
20
|
+
|
|
21
|
+
# Services
|
|
22
|
+
overmind
|
|
23
|
+
redis
|
|
24
|
+
] ++ lib.optionals stdenv.isLinux [
|
|
25
|
+
glibcLocales
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
HOST = host;
|
|
29
|
+
REDIS_URL = "redis://${host}:6379/1";
|
|
30
|
+
BUNDLE_PATH = "vendor/bundle";
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
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
|
+
gem.version = '6.6.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,7 @@ 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
|
+
gem.add_development_dependency "appraisal"
|
|
21
22
|
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
freekiqs (6.6.0)
|
|
5
|
+
sidekiq (>= 6.5.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
appraisal (2.5.0)
|
|
11
|
+
bundler
|
|
12
|
+
rake
|
|
13
|
+
thor (>= 0.14.0)
|
|
14
|
+
base64 (0.3.0)
|
|
15
|
+
connection_pool (2.5.5)
|
|
16
|
+
diff-lcs (1.6.2)
|
|
17
|
+
logger (1.7.0)
|
|
18
|
+
rack (3.2.6)
|
|
19
|
+
rake (13.4.2)
|
|
20
|
+
redis-client (0.30.1)
|
|
21
|
+
connection_pool
|
|
22
|
+
rspec (3.13.2)
|
|
23
|
+
rspec-core (~> 3.13.0)
|
|
24
|
+
rspec-expectations (~> 3.13.0)
|
|
25
|
+
rspec-mocks (~> 3.13.0)
|
|
26
|
+
rspec-core (3.13.6)
|
|
27
|
+
rspec-support (~> 3.13.0)
|
|
28
|
+
rspec-expectations (3.13.5)
|
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
30
|
+
rspec-support (~> 3.13.0)
|
|
31
|
+
rspec-mocks (3.13.8)
|
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
33
|
+
rspec-support (~> 3.13.0)
|
|
34
|
+
rspec-support (3.13.7)
|
|
35
|
+
sidekiq (7.3.10)
|
|
36
|
+
base64
|
|
37
|
+
connection_pool (>= 2.3.0, < 3)
|
|
38
|
+
logger
|
|
39
|
+
rack (>= 2.2.4, < 3.3)
|
|
40
|
+
redis-client (>= 0.23.0, < 1)
|
|
41
|
+
thor (1.5.0)
|
|
42
|
+
|
|
43
|
+
PLATFORMS
|
|
44
|
+
aarch64-linux
|
|
45
|
+
arm64-darwin
|
|
46
|
+
ruby
|
|
47
|
+
x86_64-linux
|
|
48
|
+
|
|
49
|
+
DEPENDENCIES
|
|
50
|
+
appraisal
|
|
51
|
+
freekiqs!
|
|
52
|
+
rake
|
|
53
|
+
rspec (~> 3.6)
|
|
54
|
+
sidekiq (>= 7.0.0, < 8.0.0)
|
|
55
|
+
|
|
56
|
+
BUNDLED WITH
|
|
57
|
+
4.0.10
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
freekiqs (6.6.0)
|
|
5
|
+
sidekiq (>= 6.5.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
appraisal (2.5.0)
|
|
11
|
+
bundler
|
|
12
|
+
rake
|
|
13
|
+
thor (>= 0.14.0)
|
|
14
|
+
connection_pool (3.0.2)
|
|
15
|
+
diff-lcs (1.6.2)
|
|
16
|
+
json (2.21.2)
|
|
17
|
+
logger (1.7.0)
|
|
18
|
+
rack (3.2.6)
|
|
19
|
+
rake (13.4.2)
|
|
20
|
+
redis-client (0.30.1)
|
|
21
|
+
connection_pool
|
|
22
|
+
rspec (3.13.2)
|
|
23
|
+
rspec-core (~> 3.13.0)
|
|
24
|
+
rspec-expectations (~> 3.13.0)
|
|
25
|
+
rspec-mocks (~> 3.13.0)
|
|
26
|
+
rspec-core (3.13.6)
|
|
27
|
+
rspec-support (~> 3.13.0)
|
|
28
|
+
rspec-expectations (3.13.5)
|
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
30
|
+
rspec-support (~> 3.13.0)
|
|
31
|
+
rspec-mocks (3.13.8)
|
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
33
|
+
rspec-support (~> 3.13.0)
|
|
34
|
+
rspec-support (3.13.7)
|
|
35
|
+
sidekiq (8.1.6)
|
|
36
|
+
connection_pool (>= 3.0.0)
|
|
37
|
+
json (>= 2.16.0)
|
|
38
|
+
logger (>= 1.7.0)
|
|
39
|
+
rack (>= 3.2.0)
|
|
40
|
+
redis-client (>= 0.29.0)
|
|
41
|
+
thor (1.5.0)
|
|
42
|
+
|
|
43
|
+
PLATFORMS
|
|
44
|
+
aarch64-linux
|
|
45
|
+
arm64-darwin
|
|
46
|
+
ruby
|
|
47
|
+
x86_64-linux
|
|
48
|
+
|
|
49
|
+
DEPENDENCIES
|
|
50
|
+
appraisal
|
|
51
|
+
freekiqs!
|
|
52
|
+
rake
|
|
53
|
+
rspec (~> 3.6)
|
|
54
|
+
sidekiq (>= 8.0.0, < 9.0.0)
|
|
55
|
+
|
|
56
|
+
BUNDLED WITH
|
|
57
|
+
4.0.10
|
|
@@ -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/spec/freekiqs_spec.rb
CHANGED
|
@@ -1,28 +1,49 @@
|
|
|
1
|
-
require 'sidekiq
|
|
1
|
+
require 'sidekiq'
|
|
2
|
+
require 'sidekiq/testing'
|
|
2
3
|
|
|
3
4
|
RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
4
5
|
class NonArgumentError < StandardError; end
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
module Sidekiq
|
|
8
|
+
module Middleware
|
|
9
|
+
module Server
|
|
10
|
+
class FakeTestModeEnqueueFailuresForRetry
|
|
11
|
+
def call(job_instance, job_payload, queue)
|
|
12
|
+
begin
|
|
13
|
+
yield
|
|
14
|
+
rescue => ex
|
|
15
|
+
if job_payload["retry"]
|
|
16
|
+
if job_payload["retry_count"]
|
|
17
|
+
job_payload["retry_count"] += 1
|
|
18
|
+
else
|
|
19
|
+
job_payload["retry_count"] = 0
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
max_retries = Sidekiq.default_configuration[:max_retries] || 25
|
|
23
|
+
raise if job_payload["retry_count"] >= max_retries
|
|
24
|
+
|
|
25
|
+
job_payload["queue"] = "retry"
|
|
26
|
+
job_payload["exception_class"] = ex.class
|
|
27
|
+
|
|
28
|
+
Sidekiq::Client.push(job_payload)
|
|
29
|
+
else
|
|
30
|
+
raise
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
15
37
|
end
|
|
16
38
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
job_msg = Sidekiq.dump_json(job_hash)
|
|
21
|
-
processor.process(Sidekiq::BasicFetch::UnitOfWork.new('queue:default', job_msg))
|
|
39
|
+
before do
|
|
40
|
+
Sidekiq::Worker.clear_all
|
|
41
|
+
Sidekiq::Testing.fake!
|
|
22
42
|
end
|
|
23
43
|
|
|
24
44
|
def initialize_middleware(middleware_opts={})
|
|
25
|
-
Sidekiq.server_middleware do |chain|
|
|
45
|
+
Sidekiq::Testing.server_middleware do |chain|
|
|
46
|
+
chain.add Sidekiq::Middleware::Server::FakeTestModeEnqueueFailuresForRetry
|
|
26
47
|
chain.add Sidekiq::Middleware::Server::Freekiqs, middleware_opts
|
|
27
48
|
end
|
|
28
49
|
end
|
|
@@ -40,72 +61,52 @@ RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
|
40
61
|
Object.const_set(worker_class_name, klass)
|
|
41
62
|
end
|
|
42
63
|
|
|
43
|
-
def cleanup_redis
|
|
44
|
-
Sidekiq.redis {|c| c.flushdb }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
64
|
shared_examples_for 'it should have 2 freekiqs for an ArgumentError' do
|
|
48
65
|
it 'throws Freekiq exception for specified number of freekiqs' do
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
worker_class.perform_async
|
|
67
|
+
worker_class.perform_one
|
|
68
|
+
expect(worker_class.jobs).to match_array(
|
|
69
|
+
a_hash_including(
|
|
70
|
+
"queue" => "retry",
|
|
71
|
+
"retry_count" => 0,
|
|
72
|
+
"exception_class" => "Sidekiq::FreekiqException",
|
|
73
|
+
),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
worker_class.perform_one
|
|
77
|
+
expect(worker_class.jobs).to match_array(
|
|
78
|
+
a_hash_including(
|
|
79
|
+
"queue" => "retry",
|
|
80
|
+
"retry_count" => 1,
|
|
81
|
+
"exception_class" => "Sidekiq::FreekiqException",
|
|
82
|
+
),
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
worker_class.perform_one
|
|
86
|
+
expect(worker_class.jobs).to match_array(
|
|
87
|
+
a_hash_including(
|
|
88
|
+
"queue" => "retry",
|
|
89
|
+
"retry_count" => 2,
|
|
90
|
+
"exception_class" => "ArgumentError",
|
|
91
|
+
),
|
|
92
|
+
)
|
|
76
93
|
end
|
|
77
94
|
end
|
|
78
95
|
|
|
79
96
|
shared_examples_for 'it should have 0 freekiqs for an ArgumentError' do
|
|
80
97
|
it 'raises the original error' do
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
shared_examples_for 'it should only raise exception for an ArgumentError' do
|
|
94
|
-
it 'raises the original error' do
|
|
95
|
-
args ||= []
|
|
96
|
-
expect {
|
|
97
|
-
process_job(build_job_hash(worker_class, args))
|
|
98
|
-
}.to raise_error(ArgumentError, 'Oops')
|
|
99
|
-
expect(Sidekiq::RetrySet.new.size).to eq(0)
|
|
100
|
-
# Note: Sidekiq doesn't send job to morgue when retries are diabled
|
|
101
|
-
expect(Sidekiq::DeadSet.new.size).to eq(0)
|
|
98
|
+
worker_class.perform_async
|
|
99
|
+
worker_class.perform_one
|
|
100
|
+
expect(worker_class.jobs).to match_array(
|
|
101
|
+
a_hash_including(
|
|
102
|
+
"queue" => "retry",
|
|
103
|
+
"retry_count" => 0,
|
|
104
|
+
"exception_class" => "ArgumentError",
|
|
105
|
+
),
|
|
106
|
+
)
|
|
102
107
|
end
|
|
103
108
|
end
|
|
104
109
|
|
|
105
|
-
before(:each) do
|
|
106
|
-
cleanup_redis
|
|
107
|
-
end
|
|
108
|
-
|
|
109
110
|
context 'with default middleware config' do
|
|
110
111
|
before(:each) do
|
|
111
112
|
initialize_middleware
|
|
@@ -160,8 +161,13 @@ RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
|
160
161
|
end
|
|
161
162
|
|
|
162
163
|
describe 'with 2 freekiqs in the worker and retries disabled' do
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
let!(:worker_class) { initialize_worker_class(freekiqs: 2, retry: false) }
|
|
165
|
+
|
|
166
|
+
it 'raises the original error' do
|
|
167
|
+
worker_class.perform_async
|
|
168
|
+
expect { worker_class.perform_one }.to raise_error(ArgumentError, 'Oops')
|
|
169
|
+
|
|
170
|
+
expect(worker_class.jobs.size).to eq 0
|
|
165
171
|
end
|
|
166
172
|
end
|
|
167
173
|
end
|
|
@@ -232,17 +238,34 @@ RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
|
232
238
|
called = false
|
|
233
239
|
initialize_middleware(callback: ->(worker, msg, queue){called = true})
|
|
234
240
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
241
|
+
worker_class = initialize_worker_class(freekiqs: 2)
|
|
242
|
+
worker_class.perform_async
|
|
243
|
+
worker_class.perform_one
|
|
244
|
+
|
|
245
|
+
expect(worker_class.jobs).to match_array(
|
|
246
|
+
a_hash_including(
|
|
247
|
+
"queue" => "retry",
|
|
248
|
+
"retry_count" => 0,
|
|
249
|
+
"exception_class" => "Sidekiq::FreekiqException",
|
|
250
|
+
),
|
|
251
|
+
)
|
|
252
|
+
|
|
238
253
|
expect(called).to eq(true)
|
|
239
254
|
end
|
|
240
255
|
|
|
241
256
|
it 'should still raise FreekiqException if the callback fails' do
|
|
242
257
|
initialize_middleware(callback: ->(worker, msg, queue){raise 'callback error'})
|
|
243
258
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
259
|
+
worker_class = initialize_worker_class(freekiqs: 2)
|
|
260
|
+
worker_class.perform_async
|
|
261
|
+
worker_class.perform_one
|
|
262
|
+
|
|
263
|
+
expect(worker_class.jobs).to match_array(
|
|
264
|
+
a_hash_including(
|
|
265
|
+
"queue" => "retry",
|
|
266
|
+
"retry_count" => 0,
|
|
267
|
+
"exception_class" => "Sidekiq::FreekiqException",
|
|
268
|
+
),
|
|
269
|
+
)
|
|
247
270
|
end
|
|
248
271
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -2,7 +2,9 @@ require 'freekiqs'
|
|
|
2
2
|
|
|
3
3
|
$TESTING = true
|
|
4
4
|
|
|
5
|
-
Sidekiq
|
|
5
|
+
Sidekiq.configure_server do |config|
|
|
6
|
+
config.logger = nil
|
|
7
|
+
end
|
|
6
8
|
|
|
7
9
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
8
10
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: freekiqs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rob Lewis
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: sidekiq
|
|
@@ -16,14 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 5.0
|
|
18
|
+
version: 6.5.0
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 5.0
|
|
25
|
+
version: 6.5.0
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: rspec
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -38,6 +37,20 @@ dependencies:
|
|
|
38
37
|
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: 3.6.0
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: appraisal
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
41
54
|
description: Sidekiq middleware extending RetryJobs to allow configuring how many
|
|
42
55
|
exceptions a job can throw and be wrapped by a silenceable exception.
|
|
43
56
|
email:
|
|
@@ -46,15 +59,26 @@ executables: []
|
|
|
46
59
|
extensions: []
|
|
47
60
|
extra_rdoc_files: []
|
|
48
61
|
files:
|
|
62
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
|
63
|
+
- ".github/workflows/test.yml"
|
|
49
64
|
- ".gitignore"
|
|
50
65
|
- ".rspec"
|
|
66
|
+
- Appraisals
|
|
67
|
+
- CHANGELOG.md
|
|
51
68
|
- Gemfile
|
|
69
|
+
- Gemfile.lock
|
|
52
70
|
- MIT-LICENSE
|
|
71
|
+
- Procfile
|
|
53
72
|
- README.md
|
|
54
73
|
- Rakefile
|
|
55
|
-
-
|
|
56
|
-
-
|
|
74
|
+
- development/redis/redis.conf
|
|
75
|
+
- flake.lock
|
|
76
|
+
- flake.nix
|
|
57
77
|
- freekiqs.gemspec
|
|
78
|
+
- gemfiles/sidekiq_7.gemfile
|
|
79
|
+
- gemfiles/sidekiq_7.gemfile.lock
|
|
80
|
+
- gemfiles/sidekiq_8.gemfile
|
|
81
|
+
- gemfiles/sidekiq_8.gemfile.lock
|
|
58
82
|
- lib/freekiqs.rb
|
|
59
83
|
- lib/sidekiq/middleware/server/freekiqs.rb
|
|
60
84
|
- spec/freekiqs_spec.rb
|
|
@@ -63,7 +87,6 @@ homepage: https://github.com/BookBub/freekiqs
|
|
|
63
87
|
licenses:
|
|
64
88
|
- MIT
|
|
65
89
|
metadata: {}
|
|
66
|
-
post_install_message:
|
|
67
90
|
rdoc_options: []
|
|
68
91
|
require_paths:
|
|
69
92
|
- lib
|
|
@@ -78,9 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
78
101
|
- !ruby/object:Gem::Version
|
|
79
102
|
version: '0'
|
|
80
103
|
requirements: []
|
|
81
|
-
|
|
82
|
-
rubygems_version: 2.6.11
|
|
83
|
-
signing_key:
|
|
104
|
+
rubygems_version: 3.7.2
|
|
84
105
|
specification_version: 4
|
|
85
106
|
summary: Sidekiq middleware extending RetryJobs to allow silient errors.
|
|
86
107
|
test_files:
|
data/Vagrantfile
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
Vagrant.configure(2) do |config|
|
|
2
|
-
config.vm.box = 'ubuntu/xenial64'
|
|
3
|
-
|
|
4
|
-
config.vm.network :private_network, ip: '192.168.33.69'
|
|
5
|
-
config.vm.network :forwarded_port, host: 2202, guest: 22, id: 'ssh', auto_correct: true
|
|
6
|
-
|
|
7
|
-
config.vm.synced_folder '.', '/vagrant', type: 'nfs'
|
|
8
|
-
|
|
9
|
-
config.vm.provider :virtualbox do |vb|
|
|
10
|
-
vb.name = 'freekiqs'
|
|
11
|
-
vb.memory = 2048
|
|
12
|
-
vb.cpus = 2
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
config.vm.provision :shell, inline: <<-SCRIPT
|
|
16
|
-
apt-get update
|
|
17
|
-
apt-get upgrade
|
|
18
|
-
apt-get install -y git gnupg2 redis-server
|
|
19
|
-
SCRIPT
|
|
20
|
-
|
|
21
|
-
config.vm.provision :shell, privileged: false, inline: <<-SCRIPT
|
|
22
|
-
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
|
23
|
-
curl -sSL https://get.rvm.io | bash -s stable --quiet-curl --with-gems=bundler
|
|
24
|
-
source "$HOME/.rvm/scripts/rvm"
|
|
25
|
-
rvm --quiet-curl install 2.3.4
|
|
26
|
-
rvm use 2.3.4 --default
|
|
27
|
-
cd /vagrant
|
|
28
|
-
bundle install --full-index -j4
|
|
29
|
-
echo 'cd /vagrant' >> ~/.bash_profile
|
|
30
|
-
SCRIPT
|
|
31
|
-
end
|