freekiqs 6.5.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 +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- data/.github/workflows/test.yml +29 -0
- data/.gitignore +4 -3
- data/Appraisals +7 -0
- data/CHANGELOG.md +46 -0
- data/Gemfile.lock +56 -0
- data/README.md +1 -1
- data/flake.lock +27 -0
- data/flake.nix +34 -0
- data/freekiqs.gemspec +2 -1
- 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/spec/freekiqs_spec.rb +102 -80
- data/spec/spec_helper.rb +3 -1
- metadata +28 -9
- data/Vagrantfile +0 -31
- data/circle.yml +0 -5
- data/shell.nix +0 -42
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
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/README.md
CHANGED
|
@@ -116,4 +116,4 @@ If MyWorker throws a SubMyError or MyError, it will get freekiq'd.
|
|
|
116
116
|
Version 5 of this gem only works with Sidekiq 5 and higher. If you are using
|
|
117
117
|
an older version of Sidekiq, you'll need to use version [4.1.0](https://github.com/BookBub/freekiqs/tree/v4.1.0).
|
|
118
118
|
|
|
119
|
-
Version 6.5.0 of this gem works with Sidekiq 6.5 and higher.
|
|
119
|
+
Version 6.5.0 of this gem works with Sidekiq 6.5 and higher. Last tested with Sidekiq 8.1.3.
|
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 = '6.
|
|
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.'
|
|
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
|
|
|
18
18
|
|
|
19
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
|
data/spec/freekiqs_spec.rb
CHANGED
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
require 'sidekiq'
|
|
2
|
-
require 'sidekiq/
|
|
3
|
-
require 'sidekiq/processor'
|
|
2
|
+
require 'sidekiq/testing'
|
|
4
3
|
|
|
5
4
|
RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
6
5
|
class NonArgumentError < StandardError; end
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
17
37
|
end
|
|
18
38
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
processor.process(Sidekiq::BasicFetch::UnitOfWork.new('queue:default', job_msg))
|
|
39
|
+
before do
|
|
40
|
+
Sidekiq::Worker.clear_all
|
|
41
|
+
Sidekiq::Testing.fake!
|
|
23
42
|
end
|
|
24
43
|
|
|
25
44
|
def initialize_middleware(middleware_opts={})
|
|
26
|
-
Sidekiq.server_middleware do |chain|
|
|
45
|
+
Sidekiq::Testing.server_middleware do |chain|
|
|
46
|
+
chain.add Sidekiq::Middleware::Server::FakeTestModeEnqueueFailuresForRetry
|
|
27
47
|
chain.add Sidekiq::Middleware::Server::Freekiqs, middleware_opts
|
|
28
48
|
end
|
|
29
49
|
end
|
|
@@ -41,72 +61,52 @@ RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
|
41
61
|
Object.const_set(worker_class_name, klass)
|
|
42
62
|
end
|
|
43
63
|
|
|
44
|
-
def cleanup_redis
|
|
45
|
-
Sidekiq.redis {|c| c.flushdb }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
64
|
shared_examples_for 'it should have 2 freekiqs for an ArgumentError' do
|
|
49
65
|
it 'throws Freekiq exception for specified number of freekiqs' do
|
|
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
|
-
|
|
76
|
-
|
|
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
|
+
)
|
|
77
93
|
end
|
|
78
94
|
end
|
|
79
95
|
|
|
80
96
|
shared_examples_for 'it should have 0 freekiqs for an ArgumentError' do
|
|
81
97
|
it 'raises the original error' do
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
shared_examples_for 'it should only raise exception for an ArgumentError' do
|
|
95
|
-
it 'raises the original error' do
|
|
96
|
-
args ||= []
|
|
97
|
-
expect {
|
|
98
|
-
process_job(build_job_hash(worker_class, args))
|
|
99
|
-
}.to raise_error(ArgumentError, 'Oops')
|
|
100
|
-
expect(Sidekiq::RetrySet.new.size).to eq(0)
|
|
101
|
-
# Note: Sidekiq doesn't send job to morgue when retries are diabled
|
|
102
|
-
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
|
+
)
|
|
103
107
|
end
|
|
104
108
|
end
|
|
105
109
|
|
|
106
|
-
before(:each) do
|
|
107
|
-
cleanup_redis
|
|
108
|
-
end
|
|
109
|
-
|
|
110
110
|
context 'with default middleware config' do
|
|
111
111
|
before(:each) do
|
|
112
112
|
initialize_middleware
|
|
@@ -161,8 +161,13 @@ RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
describe 'with 2 freekiqs in the worker and retries disabled' do
|
|
164
|
-
|
|
165
|
-
|
|
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
|
|
166
171
|
end
|
|
167
172
|
end
|
|
168
173
|
end
|
|
@@ -233,17 +238,34 @@ RSpec.describe Sidekiq::Middleware::Server::Freekiqs do
|
|
|
233
238
|
called = false
|
|
234
239
|
initialize_middleware(callback: ->(worker, msg, queue){called = true})
|
|
235
240
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
+
|
|
239
253
|
expect(called).to eq(true)
|
|
240
254
|
end
|
|
241
255
|
|
|
242
256
|
it 'should still raise FreekiqException if the callback fails' do
|
|
243
257
|
initialize_middleware(callback: ->(worker, msg, queue){raise 'callback error'})
|
|
244
258
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
+
)
|
|
248
270
|
end
|
|
249
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: 6.
|
|
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
|
|
@@ -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,27 +59,34 @@ 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
|
|
53
71
|
- Procfile
|
|
54
72
|
- README.md
|
|
55
73
|
- Rakefile
|
|
56
|
-
- Vagrantfile
|
|
57
|
-
- circle.yml
|
|
58
74
|
- development/redis/redis.conf
|
|
75
|
+
- flake.lock
|
|
76
|
+
- flake.nix
|
|
59
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
|
|
60
82
|
- lib/freekiqs.rb
|
|
61
83
|
- lib/sidekiq/middleware/server/freekiqs.rb
|
|
62
|
-
- shell.nix
|
|
63
84
|
- spec/freekiqs_spec.rb
|
|
64
85
|
- spec/spec_helper.rb
|
|
65
86
|
homepage: https://github.com/BookBub/freekiqs
|
|
66
87
|
licenses:
|
|
67
88
|
- MIT
|
|
68
89
|
metadata: {}
|
|
69
|
-
post_install_message:
|
|
70
90
|
rdoc_options: []
|
|
71
91
|
require_paths:
|
|
72
92
|
- lib
|
|
@@ -81,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
101
|
- !ruby/object:Gem::Version
|
|
82
102
|
version: '0'
|
|
83
103
|
requirements: []
|
|
84
|
-
rubygems_version: 3.
|
|
85
|
-
signing_key:
|
|
104
|
+
rubygems_version: 3.7.2
|
|
86
105
|
specification_version: 4
|
|
87
106
|
summary: Sidekiq middleware extending RetryJobs to allow silient errors.
|
|
88
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
|
data/circle.yml
DELETED
data/shell.nix
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
}
|