shoryuken 6.2.1 → 7.0.0.alpha1
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/.devcontainer/base.Dockerfile +1 -1
- data/.github/workflows/push.yml +36 -0
- data/.github/workflows/specs.yml +40 -27
- data/.github/workflows/verify-action-pins.yml +16 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +6 -1
- data/.ruby-version +1 -0
- data/Appraisals +10 -23
- data/CHANGELOG.md +30 -0
- data/Gemfile +1 -7
- data/README.md +2 -13
- data/Rakefile +2 -0
- data/bin/cli/sqs.rb +8 -1
- data/docker-compose.yml +22 -0
- data/gemfiles/rails_6_1.gemfile +0 -3
- data/gemfiles/rails_7_0.gemfile +0 -3
- data/gemfiles/{aws_sdk_core_2.gemfile → rails_7_1.gemfile} +1 -4
- data/gemfiles/{rails_5_2.gemfile → rails_7_2.gemfile} +2 -5
- data/gemfiles/{rails_6_0.gemfile → rails_8_0.gemfile} +2 -5
- data/lib/shoryuken/extensions/active_job_adapter.rb +5 -0
- data/lib/shoryuken/manager.rb +9 -1
- data/lib/shoryuken/options.rb +5 -0
- data/lib/shoryuken/version.rb +1 -1
- data/lib/shoryuken/worker/inline_executor.rb +6 -1
- data/lib/shoryuken.rb +3 -6
- data/renovate.json +16 -0
- data/shoryuken.gemspec +4 -1
- data/spec/integration/launcher_spec.rb +1 -1
- data/spec/shoryuken/body_parser_spec.rb +1 -2
- data/spec/shoryuken/worker/inline_executor_spec.rb +56 -0
- data/spec/spec_helper.rb +3 -4
- metadata +29 -18
- data/.codeclimate.yml +0 -20
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/stale.yml +0 -20
- data/.reek.yml +0 -5
- data/gemfiles/rails_4_2.gemfile +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46b37cd1024ac9b78cc346257df3a521866516dd0110a2caea364b436377021b
|
4
|
+
data.tar.gz: 06aac23a16d554d5d3033b486d94ff526432be33d8688718953461335cfe5520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9011b814094866790a5dc5f879631d5f7cfeed31eaefabadb273a91f52172c0ec0812ed5974a7aec2c97823e3a5125924b8d6f0576713463652c156f7db45c1
|
7
|
+
data.tar.gz: 21ccdf69621f21ea1743c1eac123893eb0e46e93c1880d9233de922542050315a2d7d8f2f93d34fad1a2a8d6c2b1c133423006db60ebd1b7ebd66ccca42fd83c
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.1, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.1-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.1-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
|
2
|
-
ARG VARIANT=
|
2
|
+
ARG VARIANT=3-bullseye
|
3
3
|
FROM ruby:${VARIANT}
|
4
4
|
|
5
5
|
# Copy library scripts to execute
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: Push Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- v*
|
7
|
+
|
8
|
+
permissions:
|
9
|
+
contents: read
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
push:
|
13
|
+
if: github.repository_owner == 'ruby-shoryuken'
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
environment: deployment
|
16
|
+
|
17
|
+
permissions:
|
18
|
+
contents: write
|
19
|
+
id-token: write
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
23
|
+
with:
|
24
|
+
fetch-depth: 0
|
25
|
+
|
26
|
+
- name: Set up Ruby
|
27
|
+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
|
28
|
+
with:
|
29
|
+
bundler-cache: false
|
30
|
+
|
31
|
+
- name: Bundle install
|
32
|
+
run: |
|
33
|
+
bundle install --jobs 4 --retry 3
|
34
|
+
|
35
|
+
# Release
|
36
|
+
- uses: rubygems/release-gem@9e85cb11501bebc2ae661c1500176316d3987059 # v1
|
data/.github/workflows/specs.yml
CHANGED
@@ -1,65 +1,78 @@
|
|
1
1
|
name: Specs
|
2
|
-
|
3
2
|
on:
|
4
3
|
- push
|
5
4
|
- pull_request
|
6
|
-
|
7
5
|
jobs:
|
8
6
|
all_specs:
|
9
7
|
name: All Specs
|
10
8
|
strategy:
|
11
9
|
matrix:
|
12
|
-
ruby: ['
|
13
|
-
gemfile: ['Gemfile'
|
14
|
-
runs-on: ubuntu-
|
15
|
-
services:
|
16
|
-
moto_sqs:
|
17
|
-
image: quay.io/cjlarose/moto-sqs-server:1.1.0
|
18
|
-
ports:
|
19
|
-
- 5000:5000
|
20
|
-
env:
|
21
|
-
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
10
|
+
ruby: ['3.0', '3.1', '3.2', '3.3', '3.4']
|
11
|
+
gemfile: ['Gemfile']
|
12
|
+
runs-on: ubuntu-latest
|
22
13
|
steps:
|
23
14
|
- name: Checkout code
|
24
|
-
uses: actions/checkout@
|
25
|
-
|
15
|
+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
16
|
+
|
17
|
+
- name: Start LocalStack
|
18
|
+
run: docker compose up -d
|
19
|
+
|
20
|
+
- name: Wait for LocalStack
|
21
|
+
run: |
|
22
|
+
timeout 30s bash -c '
|
23
|
+
until curl -s http://localhost:4566/_localstack/health | grep -q "\"sqs\": \"available\""; do
|
24
|
+
echo "Waiting for LocalStack..."
|
25
|
+
sleep 2
|
26
|
+
done
|
27
|
+
'
|
28
|
+
|
29
|
+
- uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
|
26
30
|
with:
|
27
31
|
ruby-version: ${{ matrix.ruby }}
|
28
32
|
bundler-cache: true
|
33
|
+
|
29
34
|
- name: Run specs
|
30
35
|
run: bundle exec rake spec
|
36
|
+
env:
|
37
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
38
|
+
|
31
39
|
- name: Run integration specs
|
32
40
|
run: bundle exec rake spec:integration
|
41
|
+
env:
|
42
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
43
|
+
|
33
44
|
rails_specs:
|
34
45
|
name: Rails Specs
|
35
46
|
strategy:
|
36
47
|
matrix:
|
37
|
-
rails: ['
|
48
|
+
rails: ['6.1', '7.0', '7.1', '7.2', '8.0']
|
38
49
|
include:
|
39
|
-
- rails: '4.2'
|
40
|
-
ruby: '2.2'
|
41
|
-
gemfile: gemfiles/rails_4_2.gemfile
|
42
|
-
- rails: '5.2'
|
43
|
-
ruby: '2.5'
|
44
|
-
gemfile: gemfiles/rails_5_2.gemfile
|
45
|
-
- rails: '6.0'
|
46
|
-
ruby: '2.6'
|
47
|
-
gemfile: gemfiles/rails_6_0.gemfile
|
48
50
|
- rails: '6.1'
|
49
51
|
ruby: '3.0'
|
50
52
|
gemfile: gemfiles/rails_6_1.gemfile
|
51
53
|
- rails: '7.0'
|
52
54
|
ruby: '3.1'
|
53
55
|
gemfile: gemfiles/rails_7_0.gemfile
|
54
|
-
|
56
|
+
- rails: '7.1'
|
57
|
+
ruby: '3.2'
|
58
|
+
gemfile: gemfiles/rails_7_1.gemfile
|
59
|
+
- rails: '7.2'
|
60
|
+
ruby: '3.3'
|
61
|
+
gemfile: gemfiles/rails_7_2.gemfile
|
62
|
+
- rails: '8.0'
|
63
|
+
ruby: '3.4'
|
64
|
+
gemfile: gemfiles/rails_8_0.gemfile
|
65
|
+
runs-on: ubuntu-latest
|
55
66
|
env:
|
56
67
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
57
68
|
steps:
|
58
69
|
- name: Checkout code
|
59
|
-
uses: actions/checkout@
|
60
|
-
|
70
|
+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
71
|
+
|
72
|
+
- uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
|
61
73
|
with:
|
62
74
|
ruby-version: ${{ matrix.ruby }}
|
63
75
|
bundler-cache: true
|
76
|
+
|
64
77
|
- name: Run Rails specs
|
65
78
|
run: bundle exec rake spec:rails
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Verify Action Pins
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
paths:
|
5
|
+
- '.github/workflows/**'
|
6
|
+
jobs:
|
7
|
+
verify:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
11
|
+
- name: Check SHA pins
|
12
|
+
run: |
|
13
|
+
if grep -E -r "uses: .*/.*@(v[0-9]+|main|master)($|[[:space:]]|$)" --include="*.yml" --include="*.yaml" .github/workflows/ | grep -v "#"; then
|
14
|
+
echo "::error::Actions should use SHA pins, not tags or branch names"
|
15
|
+
exit 1
|
16
|
+
fi
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.4.4
|
data/Appraisals
CHANGED
@@ -1,42 +1,29 @@
|
|
1
|
-
appraise '
|
2
|
-
group :test do
|
3
|
-
gem 'aws-sdk-core', '~> 2'
|
4
|
-
gem 'webrick' # required for Ruby 3
|
5
|
-
remove_gem 'aws-sdk-sqs'
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
appraise 'rails_4_2' do
|
1
|
+
appraise 'rails_6_1' do
|
10
2
|
group :test do
|
11
|
-
gem 'activejob', '~>
|
12
|
-
end
|
13
|
-
|
14
|
-
group :development do
|
15
|
-
gem 'appraisal', '~> 2.2'
|
16
|
-
remove_gem 'pry-byebug'
|
3
|
+
gem 'activejob', '~> 6.1'
|
17
4
|
end
|
18
5
|
end
|
19
6
|
|
20
|
-
appraise '
|
7
|
+
appraise 'rails_7_0' do
|
21
8
|
group :test do
|
22
|
-
gem 'activejob', '~>
|
9
|
+
gem 'activejob', '~> 7.0'
|
23
10
|
end
|
24
11
|
end
|
25
12
|
|
26
|
-
appraise '
|
13
|
+
appraise 'rails_7_1' do
|
27
14
|
group :test do
|
28
|
-
gem 'activejob', '~>
|
15
|
+
gem 'activejob', '~> 7.1'
|
29
16
|
end
|
30
17
|
end
|
31
18
|
|
32
|
-
appraise '
|
19
|
+
appraise 'rails_7_2' do
|
33
20
|
group :test do
|
34
|
-
gem 'activejob', '~>
|
21
|
+
gem 'activejob', '~> 7.2'
|
35
22
|
end
|
36
23
|
end
|
37
24
|
|
38
|
-
appraise '
|
25
|
+
appraise 'rails_8_0' do
|
39
26
|
group :test do
|
40
|
-
gem 'activejob', '~>
|
27
|
+
gem 'activejob', '~> 8.0'
|
41
28
|
end
|
42
29
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
## [7.0.0] - Unreleased
|
2
|
+
|
3
|
+
- Enhancement: Use -1 as thread priority
|
4
|
+
- [#825]()https://github.com/ruby-shoryuken/shoryuken/pull/825
|
5
|
+
|
6
|
+
- Enhancement: Add Support for message_attributes to InlineExecutor
|
7
|
+
- [#835](https://github.com/ruby-shoryuken/shoryuken/pull/835)
|
8
|
+
|
9
|
+
- Enhancement: Introduce trusted publishing
|
10
|
+
- [#840](https://github.com/ruby-shoryuken/shoryuken/pull/840)
|
11
|
+
|
12
|
+
- Enhancement: Add enqueue_after_transaction_commit? for Rails 7.2 compatibility
|
13
|
+
- [#777](https://github.com/ruby-shoryuken/shoryuken/pull/777)
|
14
|
+
|
15
|
+
- Enhancement: Bring Ruby 3.4 into the CI
|
16
|
+
- [#805](https://github.com/ruby-shoryuken/shoryuken/pull/805)
|
17
|
+
|
18
|
+
- Fix integration tests by updating aws-sdk-sqs and replacing moto with LocalStack
|
19
|
+
- [#782](https://github.com/ruby-shoryuken/shoryuken/pull/782)
|
20
|
+
- [#783](https://github.com/ruby-shoryuken/shoryuken/pull/783)
|
21
|
+
|
22
|
+
- Breaking: Remove support of Ruby versions older than 2.7
|
23
|
+
- [#783](https://github.com/ruby-shoryuken/shoryuken/pull/783)
|
24
|
+
|
25
|
+
- Breaking: Remove support of Rails versions older than 6.1
|
26
|
+
- [#783](https://github.com/ruby-shoryuken/shoryuken/pull/783)
|
27
|
+
|
28
|
+
- Breaking: Require `aws-sdk-sqs` `>=` `1.66`:
|
29
|
+
- [#783](https://github.com/ruby-shoryuken/shoryuken/pull/783)
|
30
|
+
|
1
31
|
## [v6.2.1] - 2024-02-09
|
2
32
|
|
3
33
|
- Bugfix: Not able to use extended polling strategy (#759)
|
data/Gemfile
CHANGED
@@ -5,12 +5,6 @@ gemspec
|
|
5
5
|
|
6
6
|
group :test do
|
7
7
|
gem 'activejob'
|
8
|
-
gem 'aws-sdk-core', '~> 3'
|
9
|
-
# Pin to 1.65.0 because of below issues:
|
10
|
-
# - https://github.com/ruby-shoryuken/shoryuken/pull/753#issuecomment-1822720647
|
11
|
-
# - https://github.com/getmoto/moto/issues/7054
|
12
|
-
gem 'aws-sdk-sqs', '1.65.0'
|
13
|
-
gem 'codeclimate-test-reporter', require: nil
|
14
8
|
gem 'httparty'
|
15
9
|
gem 'multi_xml'
|
16
10
|
gem 'simplecov'
|
@@ -19,5 +13,5 @@ end
|
|
19
13
|
group :development do
|
20
14
|
gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
|
21
15
|
gem 'pry-byebug'
|
22
|
-
gem 'rubocop'
|
16
|
+
gem 'rubocop'
|
23
17
|
end
|
data/README.md
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
**I'm looking for Shoryuken maintainers, are you interested on helping to maintain Shoryuken? [Join our Slack](https://join.slack.com/t/shoryuken/shared_invite/zt-19xjq3iqc-KmoJ6eU6~qvZNqcLzIrjww)**
|
2
|
-
|
3
1
|
# Shoryuken
|
4
2
|
|
5
3
|

|
@@ -7,7 +5,6 @@
|
|
7
5
|
Shoryuken _sho-ryu-ken_ is a super-efficient [Amazon SQS](https://aws.amazon.com/sqs/) thread-based message processor.
|
8
6
|
|
9
7
|
[](https://github.com/ruby-shoryuken/shoryuken/actions)
|
10
|
-
[](https://codeclimate.com/github/phstc/shoryuken)
|
11
8
|
|
12
9
|
## Key features
|
13
10
|
|
@@ -23,7 +20,7 @@ Shoryuken _sho-ryu-ken_ is a super-efficient [Amazon SQS](https://aws.amazon.com
|
|
23
20
|
|
24
21
|
## Requirements
|
25
22
|
|
26
|
-
Ruby
|
23
|
+
Ruby 3.0 or greater.
|
27
24
|
|
28
25
|
## Installation
|
29
26
|
|
@@ -33,14 +30,6 @@ Add this line to your application's Gemfile:
|
|
33
30
|
gem 'shoryuken'
|
34
31
|
```
|
35
32
|
|
36
|
-
If you are using AWS SDK version 3, please also add this line:
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
gem 'aws-sdk-sqs'
|
40
|
-
```
|
41
|
-
|
42
|
-
The extra gem `aws-sdk-sqs` is required in order to keep Shoryuken compatible with AWS SDK version 2 and 3.
|
43
|
-
|
44
33
|
And then execute:
|
45
34
|
|
46
35
|
```shell
|
@@ -69,7 +58,7 @@ For more information check the [wiki page](https://github.com/phstc/shoryuken/wi
|
|
69
58
|
|
70
59
|
### Testing
|
71
60
|
|
72
|
-
To run all unit specs against the latest dependency
|
61
|
+
To run all unit specs against the latest dependency versions, execute
|
73
62
|
|
74
63
|
```sh
|
75
64
|
bundle exec rake spec
|
data/Rakefile
CHANGED
data/bin/cli/sqs.rb
CHANGED
@@ -14,10 +14,17 @@ module Shoryuken
|
|
14
14
|
def normalize_dump_message(message)
|
15
15
|
# symbolize_keys is needed for keeping it compatible with `requeue`
|
16
16
|
attributes = message[:attributes].symbolize_keys
|
17
|
+
|
18
|
+
# See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_MessageAttributeValue.html
|
19
|
+
# The `string_list_values` and `binary_list_values` are not implemented. Reserved for future use.
|
20
|
+
message_attributes = message[:message_attributes].each_with_object({}) do |(k, v), result|
|
21
|
+
result[k] = v.slice(:data_type, :string_value, :binary_value)
|
22
|
+
end
|
23
|
+
|
17
24
|
{
|
18
25
|
id: message[:message_id],
|
19
26
|
message_body: message[:body],
|
20
|
-
message_attributes:
|
27
|
+
message_attributes: message_attributes,
|
21
28
|
message_deduplication_id: attributes[:MessageDeduplicationId],
|
22
29
|
message_group_id: attributes[:MessageGroupId]
|
23
30
|
}
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
services:
|
2
|
+
localstack:
|
3
|
+
image: localstack/localstack:latest
|
4
|
+
container_name: localstack
|
5
|
+
ports:
|
6
|
+
- "4566:4566"
|
7
|
+
- "4510-4559:4510-4559"
|
8
|
+
environment:
|
9
|
+
- SERVICES=sqs
|
10
|
+
- DEBUG=${DEBUG:-0}
|
11
|
+
- DOCKER_HOST=unix:///var/run/docker.sock
|
12
|
+
- AWS_DEFAULT_REGION=us-east-1
|
13
|
+
- AWS_ACCESS_KEY_ID=test
|
14
|
+
- AWS_SECRET_ACCESS_KEY=test
|
15
|
+
volumes:
|
16
|
+
- "${LOCALSTACK_VOLUME_DIR:-./.localstack}:/var/lib/localstack"
|
17
|
+
- "/var/run/docker.sock:/var/run/docker.sock"
|
18
|
+
healthcheck:
|
19
|
+
test: ["CMD", "curl", "-f", "http://localhost:4566/_localstack/health"]
|
20
|
+
interval: 5s
|
21
|
+
timeout: 10s
|
22
|
+
retries: 5
|
data/gemfiles/rails_6_1.gemfile
CHANGED
data/gemfiles/rails_7_0.gemfile
CHANGED
@@ -3,13 +3,10 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
gem "activejob"
|
7
|
-
gem "aws-sdk-core", "~> 2"
|
8
|
-
gem "codeclimate-test-reporter", require: nil
|
6
|
+
gem "activejob", "~> 7.1"
|
9
7
|
gem "httparty"
|
10
8
|
gem "multi_xml"
|
11
9
|
gem "simplecov"
|
12
|
-
gem "webrick"
|
13
10
|
end
|
14
11
|
|
15
12
|
group :development do
|
@@ -3,10 +3,7 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
gem "activejob", "~>
|
7
|
-
gem "aws-sdk-core", "~> 3"
|
8
|
-
gem "aws-sdk-sqs"
|
9
|
-
gem "codeclimate-test-reporter", require: nil
|
6
|
+
gem "activejob", "~> 7.2"
|
10
7
|
gem "httparty"
|
11
8
|
gem "multi_xml"
|
12
9
|
gem "simplecov"
|
@@ -14,7 +11,7 @@ end
|
|
14
11
|
|
15
12
|
group :development do
|
16
13
|
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
|
17
|
-
gem "pry-byebug"
|
14
|
+
gem "pry-byebug"
|
18
15
|
gem "rubocop"
|
19
16
|
end
|
20
17
|
|
@@ -3,10 +3,7 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
gem "activejob", "~>
|
7
|
-
gem "aws-sdk-core", "~> 3"
|
8
|
-
gem "aws-sdk-sqs"
|
9
|
-
gem "codeclimate-test-reporter", require: nil
|
6
|
+
gem "activejob", "~> 8.0"
|
10
7
|
gem "httparty"
|
11
8
|
gem "multi_xml"
|
12
9
|
gem "simplecov"
|
@@ -14,7 +11,7 @@ end
|
|
14
11
|
|
15
12
|
group :development do
|
16
13
|
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
|
17
|
-
gem "pry-byebug"
|
14
|
+
gem "pry-byebug"
|
18
15
|
gem "rubocop"
|
19
16
|
end
|
20
17
|
|
data/lib/shoryuken/manager.rb
CHANGED
@@ -97,7 +97,15 @@ module Shoryuken
|
|
97
97
|
fire_utilization_update_event
|
98
98
|
|
99
99
|
Concurrent::Promise
|
100
|
-
.execute(executor: @executor)
|
100
|
+
.execute(executor: @executor) do
|
101
|
+
original_priority = Thread.current.priority
|
102
|
+
begin
|
103
|
+
Thread.current.priority = Shoryuken.thread_priority
|
104
|
+
Processor.process(queue_name, sqs_msg)
|
105
|
+
ensure
|
106
|
+
Thread.current.priority = original_priority
|
107
|
+
end
|
108
|
+
end
|
101
109
|
.then { processor_done(queue_name) }
|
102
110
|
.rescue { processor_done(queue_name) }
|
103
111
|
end
|
data/lib/shoryuken/options.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Shoryuken
|
2
2
|
class Options
|
3
3
|
DEFAULTS = {
|
4
|
+
thread_priority: -1,
|
4
5
|
concurrency: 25,
|
5
6
|
queues: [],
|
6
7
|
aws: {},
|
@@ -98,6 +99,10 @@ module Shoryuken
|
|
98
99
|
Shoryuken::Logging.logger
|
99
100
|
end
|
100
101
|
|
102
|
+
def thread_priority
|
103
|
+
@thread_priority ||= options[:thread_priority]
|
104
|
+
end
|
105
|
+
|
101
106
|
def register_worker(*args)
|
102
107
|
worker_registry.register_worker(*args)
|
103
108
|
end
|
data/lib/shoryuken/version.rb
CHANGED
@@ -5,13 +5,18 @@ module Shoryuken
|
|
5
5
|
def perform_async(worker_class, body, options = {})
|
6
6
|
body = JSON.dump(body) if body.is_a?(Hash)
|
7
7
|
queue_name = options.delete(:queue) || worker_class.get_shoryuken_options['queue']
|
8
|
+
message_attributes = options.delete(:message_attributes) || {}
|
9
|
+
message_attributes['shoryuken_class'] = {
|
10
|
+
string_value: worker_class.to_s,
|
11
|
+
data_type: 'String'
|
12
|
+
}
|
8
13
|
|
9
14
|
sqs_msg = OpenStruct.new(
|
10
15
|
body: body,
|
11
16
|
attributes: nil,
|
12
17
|
md5_of_body: nil,
|
13
18
|
md5_of_message_attributes: nil,
|
14
|
-
message_attributes:
|
19
|
+
message_attributes: message_attributes,
|
15
20
|
message_id: nil,
|
16
21
|
receipt_handle: nil,
|
17
22
|
delete: nil,
|
data/lib/shoryuken.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'json'
|
3
|
-
require 'aws-sdk-
|
4
|
-
begin
|
5
|
-
require 'aws-sdk-sqs' unless defined?(Aws::SQS)
|
6
|
-
rescue LoadError
|
7
|
-
fail "AWS SDK 3 requires aws-sdk-sqs to be installed separately. Please add gem 'aws-sdk-sqs' to your Gemfile"
|
8
|
-
end
|
3
|
+
require 'aws-sdk-sqs'
|
9
4
|
require 'time'
|
10
5
|
require 'concurrent'
|
11
6
|
require 'forwardable'
|
@@ -57,6 +52,8 @@ module Shoryuken
|
|
57
52
|
:groups,
|
58
53
|
:add_queue,
|
59
54
|
:ungrouped_queues,
|
55
|
+
:thread_priority,
|
56
|
+
:thread_priority=,
|
60
57
|
:worker_registry,
|
61
58
|
:worker_registry=,
|
62
59
|
:worker_executor,
|
data/renovate.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
3
|
+
"extends": [
|
4
|
+
"config:recommended"
|
5
|
+
],
|
6
|
+
"github-actions": {
|
7
|
+
"enabled": true,
|
8
|
+
"pinDigests": true
|
9
|
+
},
|
10
|
+
"packageRules": [
|
11
|
+
{
|
12
|
+
"matchManagers": ["github-actions"],
|
13
|
+
"minimumReleaseAge": "7 days"
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
data/shoryuken.gemspec
CHANGED
@@ -18,10 +18,13 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_development_dependency 'dotenv'
|
21
|
+
spec.add_development_dependency 'ostruct'
|
21
22
|
spec.add_development_dependency 'rake'
|
22
23
|
spec.add_development_dependency 'rspec'
|
23
24
|
|
24
|
-
spec.add_dependency 'aws-sdk-
|
25
|
+
spec.add_dependency 'aws-sdk-sqs', '>= 1.66.0'
|
25
26
|
spec.add_dependency 'concurrent-ruby'
|
26
27
|
spec.add_dependency 'thor'
|
28
|
+
|
29
|
+
spec.required_ruby_version = '>= 3.0.0'
|
27
30
|
end
|
@@ -69,8 +69,7 @@ RSpec.describe Shoryuken::BodyParser do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
specify do
|
72
|
-
expect { described_class.parse(TestWorker, sqs_msg) }
|
73
|
-
.to raise_error(JSON::ParserError, /unexpected token at 'invalid JSON'/)
|
72
|
+
expect { described_class.parse(TestWorker, sqs_msg) }.to raise_error(JSON::ParserError)
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
@@ -11,6 +11,20 @@ RSpec.describe Shoryuken::Worker::InlineExecutor do
|
|
11
11
|
|
12
12
|
TestWorker.perform_async('test')
|
13
13
|
end
|
14
|
+
|
15
|
+
it 'properly sets message_attributes' do
|
16
|
+
custom_attributes = {
|
17
|
+
'custom_key' => { string_value: 'custom_value', data_type: 'String' }
|
18
|
+
}
|
19
|
+
|
20
|
+
expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msg, _|
|
21
|
+
expect(sqs_msg.message_attributes).to include('shoryuken_class')
|
22
|
+
expect(sqs_msg.message_attributes).to include('custom_key')
|
23
|
+
expect(sqs_msg.message_attributes['custom_key'][:string_value]).to eq('custom_value')
|
24
|
+
end
|
25
|
+
|
26
|
+
TestWorker.perform_async('test', message_attributes: custom_attributes)
|
27
|
+
end
|
14
28
|
end
|
15
29
|
|
16
30
|
describe '.perform_in' do
|
@@ -19,6 +33,20 @@ RSpec.describe Shoryuken::Worker::InlineExecutor do
|
|
19
33
|
|
20
34
|
TestWorker.perform_in(60, 'test')
|
21
35
|
end
|
36
|
+
|
37
|
+
it 'properly passes message_attributes to perform_async' do
|
38
|
+
custom_attributes = {
|
39
|
+
'custom_key' => { string_value: 'custom_value', data_type: 'String' }
|
40
|
+
}
|
41
|
+
|
42
|
+
expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msg, _|
|
43
|
+
expect(sqs_msg.message_attributes).to include('shoryuken_class')
|
44
|
+
expect(sqs_msg.message_attributes).to include('custom_key')
|
45
|
+
expect(sqs_msg.message_attributes['custom_key'][:string_value]).to eq('custom_value')
|
46
|
+
end
|
47
|
+
|
48
|
+
TestWorker.perform_in(60, 'test', message_attributes: custom_attributes)
|
49
|
+
end
|
22
50
|
end
|
23
51
|
|
24
52
|
context 'batch' do
|
@@ -36,6 +64,20 @@ RSpec.describe Shoryuken::Worker::InlineExecutor do
|
|
36
64
|
|
37
65
|
TestWorker.perform_async('test')
|
38
66
|
end
|
67
|
+
|
68
|
+
it 'properly passes message_attributes with batch' do
|
69
|
+
custom_attributes = {
|
70
|
+
'custom_key' => { string_value: 'custom_value', data_type: 'String' }
|
71
|
+
}
|
72
|
+
|
73
|
+
expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msgs, _|
|
74
|
+
expect(sqs_msgs.first.message_attributes).to include('shoryuken_class')
|
75
|
+
expect(sqs_msgs.first.message_attributes).to include('custom_key')
|
76
|
+
expect(sqs_msgs.first.message_attributes['custom_key'][:string_value]).to eq('custom_value')
|
77
|
+
end
|
78
|
+
|
79
|
+
TestWorker.perform_async('test', message_attributes: custom_attributes)
|
80
|
+
end
|
39
81
|
end
|
40
82
|
|
41
83
|
describe '.perform_in' do
|
@@ -44,6 +86,20 @@ RSpec.describe Shoryuken::Worker::InlineExecutor do
|
|
44
86
|
|
45
87
|
TestWorker.perform_in(60, 'test')
|
46
88
|
end
|
89
|
+
|
90
|
+
it 'properly passes message_attributes with batch' do
|
91
|
+
custom_attributes = {
|
92
|
+
'custom_key' => { string_value: 'custom_value', data_type: 'String' }
|
93
|
+
}
|
94
|
+
|
95
|
+
expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msgs, _|
|
96
|
+
expect(sqs_msgs.first.message_attributes).to include('shoryuken_class')
|
97
|
+
expect(sqs_msgs.first.message_attributes).to include('custom_key')
|
98
|
+
expect(sqs_msgs.first.message_attributes['custom_key'][:string_value]).to eq('custom_value')
|
99
|
+
end
|
100
|
+
|
101
|
+
TestWorker.perform_in(60, 'test', message_attributes: custom_attributes)
|
102
|
+
end
|
47
103
|
end
|
48
104
|
end
|
49
105
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -10,12 +10,11 @@ require 'shoryuken'
|
|
10
10
|
require 'json'
|
11
11
|
require 'dotenv'
|
12
12
|
require 'securerandom'
|
13
|
+
require 'ostruct'
|
13
14
|
Dotenv.load
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
SimpleCov.start
|
18
|
-
end
|
16
|
+
require 'simplecov'
|
17
|
+
SimpleCov.start
|
19
18
|
|
20
19
|
config_file = File.join(File.expand_path('..', __dir__), 'spec', 'shoryuken.yml')
|
21
20
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoryuken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Cantero
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: dotenv
|
@@ -24,6 +23,20 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: ostruct
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
27
40
|
- !ruby/object:Gem::Dependency
|
28
41
|
name: rake
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +66,19 @@ dependencies:
|
|
53
66
|
- !ruby/object:Gem::Version
|
54
67
|
version: '0'
|
55
68
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: aws-sdk-
|
69
|
+
name: aws-sdk-sqs
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
58
71
|
requirements:
|
59
72
|
- - ">="
|
60
73
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
74
|
+
version: 1.66.0
|
62
75
|
type: :runtime
|
63
76
|
prerelease: false
|
64
77
|
version_requirements: !ruby/object:Gem::Requirement
|
65
78
|
requirements:
|
66
79
|
- - ">="
|
67
80
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
81
|
+
version: 1.66.0
|
69
82
|
- !ruby/object:Gem::Dependency
|
70
83
|
name: concurrent-ruby
|
71
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,18 +115,17 @@ executables:
|
|
102
115
|
extensions: []
|
103
116
|
extra_rdoc_files: []
|
104
117
|
files:
|
105
|
-
- ".codeclimate.yml"
|
106
118
|
- ".devcontainer/Dockerfile"
|
107
119
|
- ".devcontainer/base.Dockerfile"
|
108
120
|
- ".devcontainer/devcontainer.json"
|
109
121
|
- ".github/FUNDING.yml"
|
110
|
-
- ".github/
|
122
|
+
- ".github/workflows/push.yml"
|
111
123
|
- ".github/workflows/specs.yml"
|
112
|
-
- ".github/workflows/
|
124
|
+
- ".github/workflows/verify-action-pins.yml"
|
113
125
|
- ".gitignore"
|
114
|
-
- ".reek.yml"
|
115
126
|
- ".rspec"
|
116
127
|
- ".rubocop.yml"
|
128
|
+
- ".ruby-version"
|
117
129
|
- Appraisals
|
118
130
|
- CHANGELOG.md
|
119
131
|
- Gemfile
|
@@ -123,15 +135,15 @@ files:
|
|
123
135
|
- bin/cli/base.rb
|
124
136
|
- bin/cli/sqs.rb
|
125
137
|
- bin/shoryuken
|
138
|
+
- docker-compose.yml
|
126
139
|
- examples/bootstrap_queues.rb
|
127
140
|
- examples/default_worker.rb
|
128
141
|
- gemfiles/.gitignore
|
129
|
-
- gemfiles/aws_sdk_core_2.gemfile
|
130
|
-
- gemfiles/rails_4_2.gemfile
|
131
|
-
- gemfiles/rails_5_2.gemfile
|
132
|
-
- gemfiles/rails_6_0.gemfile
|
133
142
|
- gemfiles/rails_6_1.gemfile
|
134
143
|
- gemfiles/rails_7_0.gemfile
|
144
|
+
- gemfiles/rails_7_1.gemfile
|
145
|
+
- gemfiles/rails_7_2.gemfile
|
146
|
+
- gemfiles/rails_8_0.gemfile
|
135
147
|
- lib/shoryuken.rb
|
136
148
|
- lib/shoryuken/body_parser.rb
|
137
149
|
- lib/shoryuken/client.rb
|
@@ -166,6 +178,7 @@ files:
|
|
166
178
|
- lib/shoryuken/worker/default_executor.rb
|
167
179
|
- lib/shoryuken/worker/inline_executor.rb
|
168
180
|
- lib/shoryuken/worker_registry.rb
|
181
|
+
- renovate.json
|
169
182
|
- shoryuken.gemspec
|
170
183
|
- shoryuken.jpg
|
171
184
|
- spec/integration/launcher_spec.rb
|
@@ -207,7 +220,6 @@ homepage: https://github.com/ruby-shoryuken/shoryuken
|
|
207
220
|
licenses:
|
208
221
|
- LGPL-3.0
|
209
222
|
metadata: {}
|
210
|
-
post_install_message:
|
211
223
|
rdoc_options: []
|
212
224
|
require_paths:
|
213
225
|
- lib
|
@@ -215,15 +227,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
227
|
requirements:
|
216
228
|
- - ">="
|
217
229
|
- !ruby/object:Gem::Version
|
218
|
-
version:
|
230
|
+
version: 3.0.0
|
219
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
232
|
requirements:
|
221
233
|
- - ">="
|
222
234
|
- !ruby/object:Gem::Version
|
223
235
|
version: '0'
|
224
236
|
requirements: []
|
225
|
-
rubygems_version: 3.
|
226
|
-
signing_key:
|
237
|
+
rubygems_version: 3.6.7
|
227
238
|
specification_version: 4
|
228
239
|
summary: Shoryuken is a super efficient AWS SQS thread based message processor
|
229
240
|
test_files:
|
data/.codeclimate.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
---
|
2
|
-
engines:
|
3
|
-
reek:
|
4
|
-
enabled: true
|
5
|
-
duplication:
|
6
|
-
enabled: true
|
7
|
-
config:
|
8
|
-
languages:
|
9
|
-
- ruby
|
10
|
-
fixme:
|
11
|
-
enabled: true
|
12
|
-
rubocop:
|
13
|
-
enabled: true
|
14
|
-
config:
|
15
|
-
file: .rubocop.yml
|
16
|
-
ratings:
|
17
|
-
paths:
|
18
|
-
- "**.rb"
|
19
|
-
exclude_paths:
|
20
|
-
- spec/
|
data/.github/dependabot.yml
DELETED
data/.github/workflows/stale.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
name: "Close stale issues and PRs"
|
2
|
-
on:
|
3
|
-
schedule:
|
4
|
-
- cron: "30 1 * * *" # At 01:30 - https://crontab.guru/#30_1_*_*_*
|
5
|
-
workflow_dispatch: {}
|
6
|
-
jobs:
|
7
|
-
stale:
|
8
|
-
runs-on: ubuntu-latest
|
9
|
-
permissions:
|
10
|
-
issues: write
|
11
|
-
pull-requests: write
|
12
|
-
steps:
|
13
|
-
- uses: actions/stale@v9
|
14
|
-
with:
|
15
|
-
stale-issue-message: This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
|
16
|
-
stale-pr-message: This PR is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
|
17
|
-
close-issue-message: This issue was closed because it hasn't seen activity for a while.
|
18
|
-
close-pr-message: This PR was closed because it hasn't seen activity for a while.
|
19
|
-
days-before-stale: 60
|
20
|
-
days-before-close: 7
|
data/.reek.yml
DELETED
data/gemfiles/rails_4_2.gemfile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
group :test do
|
6
|
-
gem "activejob", "~> 4.2"
|
7
|
-
gem "aws-sdk-core", "~> 3"
|
8
|
-
gem "aws-sdk-sqs"
|
9
|
-
gem "codeclimate-test-reporter", require: nil
|
10
|
-
gem "httparty"
|
11
|
-
gem "multi_xml"
|
12
|
-
gem "simplecov"
|
13
|
-
end
|
14
|
-
|
15
|
-
group :development do
|
16
|
-
gem "appraisal", "~> 2.2"
|
17
|
-
gem "rubocop"
|
18
|
-
end
|
19
|
-
|
20
|
-
gemspec path: "../"
|