ears 0.10.1 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +1 -1
- data/.github/workflows/codeql.yml +76 -0
- data/.github/workflows/dependency-review.yml +20 -0
- data/.tool-versions +1 -1
- data/CHANGELOG.md +10 -0
- data/CODEOWNERS +1 -1
- data/Gemfile.lock +17 -12
- data/README.md +4 -1
- data/ears.gemspec +1 -1
- data/lib/ears/configuration.rb +20 -0
- data/lib/ears/errors.rb +5 -0
- data/lib/ears/version.rb +1 -1
- data/lib/ears.rb +18 -4
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5b2a2c4de31a20aa629cb7b7ae7a5c6e25208939e352e4bb49100a6f8edcfc1
|
4
|
+
data.tar.gz: d45e78a7922c5ec18d3fa67aed15b4125281235fe1df34131e3698163a234617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ff0a50540f11484caa4b9c7f13b4bb5f6734f3c9505e7ea715e3429fbca41cb40392ba4788e0ca7390e550899ab79cb3fdecdb0a8d1d4b042493f56f3f833d8
|
7
|
+
data.tar.gz: d7618d2cb3b43ccf168136b7a40e6b4ca82b40569cbf64dcbaf485135f1977d76b4a78b40f811f63cb47f4781353d871889957cf26333097a85520c31bf0dca8
|
data/.github/workflows/build.yml
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
2
|
+
# to commit it to your repository.
|
3
|
+
#
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
+
# or to provide custom queries or build logic.
|
6
|
+
#
|
7
|
+
# ******** NOTE ********
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
+
# supported CodeQL languages.
|
11
|
+
#
|
12
|
+
name: 'CodeQL'
|
13
|
+
|
14
|
+
on:
|
15
|
+
push:
|
16
|
+
branches: ['main']
|
17
|
+
pull_request:
|
18
|
+
# The branches below must be a subset of the branches above
|
19
|
+
branches: ['main']
|
20
|
+
schedule:
|
21
|
+
- cron: '15 9 * * 2'
|
22
|
+
|
23
|
+
jobs:
|
24
|
+
analyze:
|
25
|
+
name: Analyze
|
26
|
+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
27
|
+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
|
28
|
+
permissions:
|
29
|
+
actions: read
|
30
|
+
contents: read
|
31
|
+
security-events: write
|
32
|
+
|
33
|
+
strategy:
|
34
|
+
fail-fast: false
|
35
|
+
matrix:
|
36
|
+
language: ['ruby']
|
37
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
|
38
|
+
# Use only 'java' to analyze code written in Java, Kotlin or both
|
39
|
+
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
|
40
|
+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
41
|
+
|
42
|
+
steps:
|
43
|
+
- name: Checkout repository
|
44
|
+
uses: actions/checkout@v3
|
45
|
+
|
46
|
+
# Initializes the CodeQL tools for scanning.
|
47
|
+
- name: Initialize CodeQL
|
48
|
+
uses: github/codeql-action/init@v2
|
49
|
+
with:
|
50
|
+
languages: ${{ matrix.language }}
|
51
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
52
|
+
# By default, queries listed here will override any specified in a config file.
|
53
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
54
|
+
|
55
|
+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
56
|
+
# queries: security-extended,security-and-quality
|
57
|
+
|
58
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
|
59
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
60
|
+
- name: Autobuild
|
61
|
+
uses: github/codeql-action/autobuild@v2
|
62
|
+
|
63
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
64
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
65
|
+
|
66
|
+
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
67
|
+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
68
|
+
|
69
|
+
# - run: |
|
70
|
+
# echo "Run, Build Application using script"
|
71
|
+
# ./location_of_script_within_repo/buildscript.sh
|
72
|
+
|
73
|
+
- name: Perform CodeQL Analysis
|
74
|
+
uses: github/codeql-action/analyze@v2
|
75
|
+
with:
|
76
|
+
category: '/language:${{matrix.language}}'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Dependency Review Action
|
2
|
+
#
|
3
|
+
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
|
4
|
+
#
|
5
|
+
# Source repository: https://github.com/actions/dependency-review-action
|
6
|
+
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
|
7
|
+
name: 'Dependency Review'
|
8
|
+
on: [pull_request]
|
9
|
+
|
10
|
+
permissions:
|
11
|
+
contents: read
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
dependency-review:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
steps:
|
17
|
+
- name: 'Checkout Repository'
|
18
|
+
uses: actions/checkout@v3
|
19
|
+
- name: 'Dependency Review'
|
20
|
+
uses: actions/dependency-review-action@v2
|
data/.tool-versions
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
ruby 3.2.2
|
2
|
-
nodejs 20.
|
2
|
+
nodejs 20.2.0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.11.1 (2023-09-08)
|
4
|
+
|
5
|
+
- Bugfix: trapped signals INT and TERM now calls correctly previous set signal handler
|
6
|
+
|
7
|
+
## 0.11.0 (2023-05-30)
|
8
|
+
|
9
|
+
- **[Breaking]**: Provide the Bunny connection option `recovery_attempts` in Ears configuration. It
|
10
|
+
comes with a default of 10 attempts. When the number of recovery attempts are exhausted, Ears will
|
11
|
+
raise a `MaxRecoveryAttemptsExhaustedError`.
|
12
|
+
|
3
13
|
## 0.10.1 (2023-05-22)
|
4
14
|
|
5
15
|
- Reset channel on Ears.stop!
|
data/CODEOWNERS
CHANGED
@@ -1 +1 @@
|
|
1
|
-
* @
|
1
|
+
* @johannesluedke @brerx
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ears (0.
|
5
|
-
bunny
|
4
|
+
ears (0.11.1)
|
5
|
+
bunny (~> 2.22.0)
|
6
6
|
multi_json
|
7
7
|
|
8
8
|
GEM
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
amq-protocol (2.3.2)
|
12
12
|
ast (2.4.2)
|
13
|
-
bunny (2.
|
13
|
+
bunny (2.22.0)
|
14
14
|
amq-protocol (~> 2.3, >= 2.3.1)
|
15
15
|
sorted_set (~> 1, >= 1.0.2)
|
16
16
|
diff-lcs (1.5.0)
|
@@ -21,16 +21,18 @@ GEM
|
|
21
21
|
json (2.6.3)
|
22
22
|
multi_json (1.15.0)
|
23
23
|
parallel (1.23.0)
|
24
|
-
parser (3.2.2.
|
24
|
+
parser (3.2.2.3)
|
25
25
|
ast (~> 2.4.1)
|
26
|
+
racc
|
26
27
|
prettier (3.2.2)
|
27
28
|
syntax_tree (>= 2.7.1)
|
28
29
|
syntax_tree-haml (>= 1.1.0)
|
29
30
|
syntax_tree-rbs (>= 0.2.0)
|
30
31
|
prettier_print (1.2.1)
|
32
|
+
racc (1.7.0)
|
31
33
|
rainbow (3.1.1)
|
32
34
|
rake (13.0.6)
|
33
|
-
rbs (3.0
|
35
|
+
rbs (3.1.0)
|
34
36
|
rbtree (0.4.6)
|
35
37
|
redcarpet (3.6.0)
|
36
38
|
regexp_parser (2.8.0)
|
@@ -48,7 +50,7 @@ GEM
|
|
48
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
51
|
rspec-support (~> 3.12.0)
|
50
52
|
rspec-support (3.12.0)
|
51
|
-
rubocop (1.
|
53
|
+
rubocop (1.52.0)
|
52
54
|
json (~> 2.3)
|
53
55
|
parallel (~> 1.10)
|
54
56
|
parser (>= 3.2.0.0)
|
@@ -58,15 +60,18 @@ GEM
|
|
58
60
|
rubocop-ast (>= 1.28.0, < 2.0)
|
59
61
|
ruby-progressbar (~> 1.7)
|
60
62
|
unicode-display_width (>= 2.4.0, < 3.0)
|
61
|
-
rubocop-ast (1.
|
63
|
+
rubocop-ast (1.29.0)
|
62
64
|
parser (>= 3.2.1.0)
|
63
65
|
rubocop-capybara (2.18.0)
|
64
66
|
rubocop (~> 1.41)
|
67
|
+
rubocop-factory_bot (2.23.1)
|
68
|
+
rubocop (~> 1.33)
|
65
69
|
rubocop-rake (0.6.0)
|
66
70
|
rubocop (~> 1.0)
|
67
|
-
rubocop-rspec (2.
|
71
|
+
rubocop-rspec (2.22.0)
|
68
72
|
rubocop (~> 1.33)
|
69
73
|
rubocop-capybara (~> 2.17)
|
74
|
+
rubocop-factory_bot (~> 2.22)
|
70
75
|
ruby-progressbar (1.13.0)
|
71
76
|
set (1.0.3)
|
72
77
|
sorted_set (1.0.3)
|
@@ -82,9 +87,9 @@ GEM
|
|
82
87
|
prettier_print
|
83
88
|
rbs
|
84
89
|
syntax_tree (>= 2.0.1)
|
85
|
-
temple (0.10.
|
86
|
-
thor (1.2.
|
87
|
-
tilt (2.
|
90
|
+
temple (0.10.2)
|
91
|
+
thor (1.2.2)
|
92
|
+
tilt (2.2.0)
|
88
93
|
unicode-display_width (2.4.2)
|
89
94
|
yard (0.9.34)
|
90
95
|
|
@@ -109,4 +114,4 @@ DEPENDENCIES
|
|
109
114
|
yard
|
110
115
|
|
111
116
|
BUNDLED WITH
|
112
|
-
2.4.
|
117
|
+
2.4.13
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
`Ears` is a small, simple library for writing RabbitMQ consumers.
|
4
4
|
|
5
|
+
[![CodeQL](https://github.com/ivx/ears/actions/workflows/codeql.yml/badge.svg)](https://github.com/ivx/ears/actions/workflows/codeql.yml)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -30,7 +32,8 @@ require 'ears'
|
|
30
32
|
Ears.configure do |config|
|
31
33
|
config.rabbitmq_url = 'amqp://user:password@myrmq:5672'
|
32
34
|
config.connection_name = 'My Consumer'
|
33
|
-
config.recover_from_connection_close = false
|
35
|
+
config.recover_from_connection_close = false # optional configuration, defaults to true if not set
|
36
|
+
config.recovery_attempts = 3 # optional configuration, defaults to 10, Bunny::Session would have been nil
|
34
37
|
end
|
35
38
|
```
|
36
39
|
|
data/ears.gemspec
CHANGED
@@ -38,6 +38,6 @@ You may want to have a look into the CHANGELOG!
|
|
38
38
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
39
39
|
spec.require_paths = ['lib']
|
40
40
|
|
41
|
-
spec.add_dependency 'bunny'
|
41
|
+
spec.add_dependency 'bunny', '~> 2.22.0'
|
42
42
|
spec.add_dependency 'multi_json'
|
43
43
|
end
|
data/lib/ears/configuration.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ears/errors'
|
2
|
+
|
1
3
|
module Ears
|
2
4
|
# The class representing the global {Ears} configuration.
|
3
5
|
class Configuration
|
@@ -5,6 +7,7 @@ module Ears
|
|
5
7
|
end
|
6
8
|
|
7
9
|
DEFAULT_RABBITMQ_URL = 'amqp://guest:guest@localhost:5672'
|
10
|
+
DEFAULT_RECOVERY_ATTEMPTS = 10
|
8
11
|
|
9
12
|
# @return [String] the connection string for RabbitMQ.
|
10
13
|
attr_accessor :rabbitmq_url
|
@@ -15,8 +18,25 @@ module Ears
|
|
15
18
|
# @return [Boolean] if the recover_from_connection_close value is set for the RabbitMQ connection.
|
16
19
|
attr_accessor :recover_from_connection_close
|
17
20
|
|
21
|
+
# @return [Integer] max number of recovery attempts, nil means forever
|
22
|
+
attr_accessor :recovery_attempts
|
23
|
+
|
18
24
|
def initialize
|
19
25
|
@rabbitmq_url = DEFAULT_RABBITMQ_URL
|
26
|
+
@recovery_attempts = DEFAULT_RECOVERY_ATTEMPTS
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Proc] that is passed to Bunny’s recovery_attempts_exhausted block. Nil if recovery_attempts is nil.
|
30
|
+
def recovery_attempts_exhausted
|
31
|
+
return nil unless recovery_attempts
|
32
|
+
|
33
|
+
Proc.new do
|
34
|
+
# We need to have this since Bunny’s multi-threading is cumbersome here.
|
35
|
+
# Session reconnection seems not to be done in the main thread. If we want to
|
36
|
+
# achieve a restart of the app we need to modify the thread behaviour.
|
37
|
+
Thread.current.abort_on_exception = true
|
38
|
+
raise MaxRecoveryAttemptsExhaustedError
|
39
|
+
end
|
20
40
|
end
|
21
41
|
|
22
42
|
def validate!
|
data/lib/ears/errors.rb
ADDED
data/lib/ears/version.rb
CHANGED
data/lib/ears.rb
CHANGED
@@ -51,10 +51,9 @@ module Ears
|
|
51
51
|
# Blocks the calling thread until +SIGTERM+ or +SIGINT+ is received.
|
52
52
|
# Used to keep the process alive while processing messages.
|
53
53
|
def run!
|
54
|
-
running = true
|
55
|
-
|
56
|
-
|
57
|
-
sleep 1 while running && @error.nil?
|
54
|
+
@running = true
|
55
|
+
setup_traps
|
56
|
+
sleep 1 while @running && @error.nil?
|
58
57
|
raise @error if @error
|
59
58
|
end
|
60
59
|
|
@@ -82,11 +81,26 @@ module Ears
|
|
82
81
|
|
83
82
|
private
|
84
83
|
|
84
|
+
def setup_traps
|
85
|
+
@previous_int_trap =
|
86
|
+
Signal.trap('INT') do
|
87
|
+
@running = false
|
88
|
+
@previous_int_trap&.call unless @previous_int_trap == 'DEFAULT'
|
89
|
+
end
|
90
|
+
@previous_term_trap =
|
91
|
+
Signal.trap('TERM') do
|
92
|
+
@running = false
|
93
|
+
@previous_term_trap&.call unless @previous_term_trap == 'DEFAULT'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
85
97
|
def connection_config
|
86
98
|
{
|
87
99
|
connection_name: configuration.connection_name,
|
88
100
|
recover_from_connection_close:
|
89
101
|
configuration.recover_from_connection_close,
|
102
|
+
recovery_attempts: configuration.recovery_attempts,
|
103
|
+
recovery_attempts_exhausted: configuration.recovery_attempts_exhausted,
|
90
104
|
}.compact
|
91
105
|
end
|
92
106
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ears
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InVision AG
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.22.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:
|
26
|
+
version: 2.22.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: multi_json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,6 +46,8 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".github/workflows/build.yml"
|
49
|
+
- ".github/workflows/codeql.yml"
|
50
|
+
- ".github/workflows/dependency-review.yml"
|
49
51
|
- ".gitignore"
|
50
52
|
- ".rspec"
|
51
53
|
- ".rubocop.yml"
|
@@ -63,6 +65,7 @@ files:
|
|
63
65
|
- lib/ears/configuration.rb
|
64
66
|
- lib/ears/consumer.rb
|
65
67
|
- lib/ears/consumer_wrapper.rb
|
68
|
+
- lib/ears/errors.rb
|
66
69
|
- lib/ears/middleware.rb
|
67
70
|
- lib/ears/middlewares/appsignal.rb
|
68
71
|
- lib/ears/middlewares/json.rb
|