ears 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ff51eb26ddd79aebd5f99d8699b8351cdc96fc68485e9b0c99a8fe85502a96e
4
- data.tar.gz: 91667d959259121b6e973897fb617cb0b92e60b720c6aee451c8ff5b472f6c58
3
+ metadata.gz: c78842e806da5fc1ccc47697cd55a94e3f038fae3e0dc3688a6fa0b55bb1f4e5
4
+ data.tar.gz: 3def90d115c5845bb4a0339465cf705447bf5398693913cc0e2080828ad86f93
5
5
  SHA512:
6
- metadata.gz: fc487ab5e78bb55e43c6ccb89fb1d49543f1c3994b1bf3b01b1f4f6349ede74570ff6c6c67be5c1b1d979a4328124cf333db1594f3fde7cc2cdb54397ed3461c
7
- data.tar.gz: 6f5e2efd6c25c8ff2801d3402064b20ec808b56530a7f65ad55323da549f0583ec5e4f06a66baec83b7b6ebf532bdab644095ac7880a544143ffcd2c73d5ee64
6
+ metadata.gz: ec53642022e0db616224c8beea49931d8be0ed5e89120e7e81729fd6c2dbe8713522db77e955c5b4231bb41f1f9de82bd613b64cc6d3760fbe1c0cbbfc15c550
7
+ data.tar.gz: 62f101c0c19bcc5ef27ef220783bd73132b79a9d413d9f45b1642556de091738a6cd3e4817d6e9d5914aa39fac575dd4e9f585c8cedfae68bbc7808faedf5ebd
@@ -23,7 +23,7 @@ jobs:
23
23
  bundler-cache: true
24
24
  - uses: actions/setup-node@v3
25
25
  with:
26
- node-version: '18'
26
+ node-version: '20'
27
27
  - name: Run prettier
28
28
  run: npm ci && npm run lint
29
29
  - name: Run Rubocop
@@ -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.0.0
2
+ nodejs 20.2.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0 (2023-05-30)
4
+
5
+ - **[Breaking]**: Provide the Bunny connection option `recovery_attempts` in Ears configuration. It
6
+ comes with a default of 10 attempts. When the number of recovery attempts are exhausted, Ears will
7
+ raise a `MaxRecoveryAttemptsExhaustedError`.
8
+
9
+ ## 0.10.1 (2023-05-22)
10
+
11
+ - Reset channel on Ears.stop!
12
+
3
13
  ## 0.10.0 (2023-05-16)
4
14
 
5
15
  - Add Ears.stop! method to be able to close the connection and remove consumers.
data/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @ivx/schedules
1
+ * @johannesluedke @brerx
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ears (0.10.0)
5
- bunny
4
+ ears (0.11.0)
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.20.3)
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.1)
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.4)
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.50.2)
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.28.0)
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.20.0)
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.0)
86
- thor (1.2.1)
87
- tilt (2.1.0)
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.12
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, # optional configuration, defaults to true if not set
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
 
@@ -212,7 +215,7 @@ For this use case, there is a stop! method:
212
215
  Ears.stop!
213
216
  ```
214
217
 
215
- It will close and reset the current Bunny connection, leading to all consumers being shut down.
218
+ It will close and reset the current Bunny connection, leading to all consumers being shut down. Also, it will reset the channel.
216
219
 
217
220
  ## Documentation
218
221
 
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
@@ -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!
@@ -0,0 +1,5 @@
1
+ module Ears
2
+ # Error that is raised when the Bunny recovery attempts are exhausted.
3
+ class MaxRecoveryAttemptsExhaustedError < StandardError
4
+ end
5
+ end
data/lib/ears/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ears
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
data/lib/ears.rb CHANGED
@@ -62,6 +62,7 @@ module Ears
62
62
  def stop!
63
63
  connection.close
64
64
  @connection = nil
65
+ Thread.current[:ears_channel] = nil
65
66
  end
66
67
 
67
68
  # Signals that an uncaught error has occurred and the process should be stopped.
@@ -86,6 +87,8 @@ module Ears
86
87
  connection_name: configuration.connection_name,
87
88
  recover_from_connection_close:
88
89
  configuration.recover_from_connection_close,
90
+ recovery_attempts: configuration.recovery_attempts,
91
+ recovery_attempts_exhausted: configuration.recovery_attempts_exhausted,
89
92
  }.compact
90
93
  end
91
94
  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.10.0
4
+ version: 0.11.0
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-05-16 00:00:00.000000000 Z
11
+ date: 2023-06-29 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: '0'
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: '0'
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