ears 0.8.0 → 0.8.2
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/workflows/build.yml +1 -1
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/ears.gemspec +1 -1
- data/lib/ears/middlewares/json.rb +9 -5
- data/lib/ears/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7f0db6c78f5ce2d0271dbae56ef2200480127130d604168f701e6562bad0a19
|
4
|
+
data.tar.gz: '03821a363301d6acc349e026cc5c152053ae8296ecc3f022f5f04b8572643e32'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97e737054d37b2856e8184cebe1ff623ec7e6289989454c529fe840ab2f9ddcbabc55ccd382bba17e744f0fdaa59bb79aa387d3119bf5b478dd4180b824c4482
|
7
|
+
data.tar.gz: 474208916ad8388c351e0a5c220dd6981b33c2d9f39775bfb4b9d8606e25eff38118b19003da28c00c250f7d1b99ebefaf749607cd17dee5cb4aba5960e2c6e9
|
data/.github/workflows/build.yml
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.8.2 (2022-11-25)
|
4
|
+
|
5
|
+
- default JSON middleware error handler to reject
|
6
|
+
|
7
|
+
## 0.8.1 (2022-04-08)
|
8
|
+
|
9
|
+
- do not rescue errors outside the scope of the error handler in JSON middleware
|
10
|
+
|
3
11
|
## 0.8.0 (2022-04-08)
|
4
12
|
|
5
13
|
- JSON middleware now requires an `on_error` callback in the options
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -92,8 +92,9 @@ require 'ears/middlewares/json'
|
|
92
92
|
|
93
93
|
class MyConsumer < Ears::Consumer
|
94
94
|
# register the JSON middleware and don't symbolize keys (this can be omitted, the default is true)
|
95
|
+
# and nack the message on parsing error. This defaults to Proc.new { :reject }.
|
95
96
|
use Ears::Middlewares::JSON,
|
96
|
-
on_error: Proc.new { :
|
97
|
+
on_error: Proc.new { :nack },
|
97
98
|
symbolize_keys: false
|
98
99
|
|
99
100
|
def work(delivery_info, metadata, payload)
|
data/ears.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = 'A gem for building RabbitMQ consumers.'
|
11
11
|
spec.homepage = 'https://github.com/ivx/ears'
|
12
12
|
spec.license = 'MIT'
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
14
14
|
|
15
15
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
16
16
|
|
@@ -6,19 +6,23 @@ module Ears
|
|
6
6
|
# A middleware that automatically parses your JSON payload.
|
7
7
|
class JSON < Middleware
|
8
8
|
# @param [Hash] opts The options for the middleware.
|
9
|
-
# @option opts [Proc] :on_error A Proc to be called when an error occurs during processing
|
9
|
+
# @option opts [Proc] :on_error (Proc.new { :reject }) A Proc to be called when an error occurs during processing.
|
10
10
|
# @option opts [Boolean] :symbolize_keys (true) Whether to symbolize the keys of your payload.
|
11
11
|
def initialize(opts = {})
|
12
12
|
super()
|
13
|
-
@on_error = opts.fetch(:on_error)
|
13
|
+
@on_error = opts.fetch(:on_error, Proc.new { :reject })
|
14
14
|
@symbolize_keys = opts.fetch(:symbolize_keys, true)
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(delivery_info, metadata, payload, app)
|
18
|
-
|
18
|
+
begin
|
19
|
+
parsed_payload =
|
20
|
+
MultiJson.load(payload, symbolize_keys: symbolize_keys)
|
21
|
+
rescue => e
|
22
|
+
return on_error.call(e)
|
23
|
+
end
|
24
|
+
|
19
25
|
app.call(delivery_info, metadata, parsed_payload)
|
20
|
-
rescue => e
|
21
|
-
on_error.call(e)
|
22
26
|
end
|
23
27
|
|
24
28
|
private
|
data/lib/ears/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ears
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Mainz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -187,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
187
|
requirements:
|
188
188
|
- - ">="
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version: 2.
|
190
|
+
version: 2.7.0
|
191
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
192
|
requirements:
|
193
193
|
- - ">="
|