ears 0.8.1 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a270323620cabe6ab7cee7c3c9df9027e8ae7881391725ee8f2208c7f25daf1
4
- data.tar.gz: 89b4c68b826969e361c57a1f10443cb2b7d9e05e7e7927ab41625b18cc2f9909
3
+ metadata.gz: e7efe81a9b7a340a2f18828532f5b8833d88ffa1094bd5cef713c18e89282431
4
+ data.tar.gz: 6245d445274e10936fa39d9423e83f6d433f9533ce72503ea9141ece31686b4e
5
5
  SHA512:
6
- metadata.gz: 6ecbaea2a5bcbfab38dc08614a007aab1062b88b6a1245d8234039532ae7cab6085593aecade33f13e115952b2fb616a310d254ee7a5e2287f9b64704ad88136
7
- data.tar.gz: 8bcfea156458b3e6c2c16bd319e181dca1c21edf8616b1015d7f7f11c7a7513865ee1a8f75f5e041a0f8875c3f2a8c216b0f6e45f0215e03750b3a1391a62367
6
+ metadata.gz: 4db3e60aa2b01c98ebf93d3edd08978cc2bb3d9eb069549fb26ad8c7ceafd384cb5bd7d0843ea4ad12e531f763a94f3764e194488cee488bc313802ad926706b
7
+ data.tar.gz: 915ff3b6aac612ac08a9db8d8ce4947c42e8dfff4be8927300ec0f135cc01e5891170f5a4260fb1bb70a13dc6afa3b6e5b6981593ed9400b2090a08451ad35e1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0 (2023-01-09)
4
+
5
+ - Add option to configure recover_from_connection_close
6
+
7
+ ## 0.8.2 (2022-11-25)
8
+
9
+ - default JSON middleware error handler to reject
10
+
3
11
  ## 0.8.1 (2022-04-08)
4
12
 
5
13
  - do not rescue errors outside the scope of the error handler in JSON middleware
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ears (0.8.1)
4
+ ears (0.9.0)
5
5
  bunny
6
6
  multi_json
7
7
 
@@ -10,7 +10,7 @@ GEM
10
10
  specs:
11
11
  amq-protocol (2.3.2)
12
12
  ast (2.4.2)
13
- bunny (2.19.0)
13
+ bunny (2.20.1)
14
14
  amq-protocol (~> 2.3, >= 2.3.1)
15
15
  sorted_set (~> 1, >= 1.0.2)
16
16
  diff-lcs (1.4.4)
@@ -20,7 +20,7 @@ GEM
20
20
  ast (~> 2.4.1)
21
21
  rainbow (3.0.0)
22
22
  rake (13.0.6)
23
- rbtree (0.4.5)
23
+ rbtree (0.4.6)
24
24
  redcarpet (3.5.1)
25
25
  regexp_parser (2.1.1)
26
26
  rexml (3.2.5)
@@ -54,7 +54,7 @@ GEM
54
54
  rubocop (~> 1.0)
55
55
  rubocop-ast (>= 1.1.0)
56
56
  ruby-progressbar (1.11.0)
57
- set (1.0.2)
57
+ set (1.0.3)
58
58
  sorted_set (1.0.3)
59
59
  rbtree
60
60
  set (~> 1.0)
@@ -65,6 +65,7 @@ PLATFORMS
65
65
  arm64-darwin-20
66
66
  arm64-darwin-21
67
67
  x86_64-darwin-20
68
+ x86_64-darwin-21
68
69
  x86_64-linux
69
70
 
70
71
  DEPENDENCIES
data/README.md CHANGED
@@ -30,6 +30,7 @@ require 'ears'
30
30
  Ears.configure do |config|
31
31
  config.rabbitmq_url = 'amqp://user:password@myrmq:5672'
32
32
  config.connection_name = 'My Consumer'
33
+ config.recover_from_connection_close = false, # optional configuration, defaults to true if not set
33
34
  end
34
35
  ```
35
36
 
@@ -92,8 +93,9 @@ require 'ears/middlewares/json'
92
93
 
93
94
  class MyConsumer < Ears::Consumer
94
95
  # register the JSON middleware and don't symbolize keys (this can be omitted, the default is true)
96
+ # and nack the message on parsing error. This defaults to Proc.new { :reject }.
95
97
  use Ears::Middlewares::JSON,
96
- on_error: Proc.new { :reject },
98
+ on_error: Proc.new { :nack },
97
99
  symbolize_keys: false
98
100
 
99
101
  def work(delivery_info, metadata, payload)
@@ -12,6 +12,9 @@ module Ears
12
12
  # @return [String] the name for the RabbitMQ connection.
13
13
  attr_accessor :connection_name
14
14
 
15
+ # @return [Boolean] if the recover_from_connection_close value is set for the RabbitMQ connection.
16
+ attr_accessor :recover_from_connection_close
17
+
15
18
  def initialize
16
19
  @rabbitmq_url = DEFAULT_RABBITMQ_URL
17
20
  end
@@ -6,11 +6,11 @@ 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
 
data/lib/ears/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ears
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
data/lib/ears.rb CHANGED
@@ -27,10 +27,7 @@ module Ears
27
27
  def connection
28
28
  @connection ||=
29
29
  Bunny
30
- .new(
31
- configuration.rabbitmq_url,
32
- connection_name: configuration.connection_name,
33
- )
30
+ .new(configuration.rabbitmq_url, **connection_config)
34
31
  .tap { |conn| conn.start }
35
32
  end
36
33
 
@@ -76,5 +73,15 @@ module Ears
76
73
  @configuration = nil
77
74
  Thread.current[:ears_channel] = nil
78
75
  end
76
+
77
+ private
78
+
79
+ def connection_config
80
+ {
81
+ connection_name: configuration.connection_name,
82
+ recover_from_connection_close:
83
+ configuration.recover_from_connection_close,
84
+ }.compact
85
+ end
79
86
  end
80
87
  end
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.1
4
+ version: 0.9.0
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-04-08 00:00:00.000000000 Z
11
+ date: 2023-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny