Skip to content

Commit b2b2b26

Browse files
authored
Merge pull request #31 from Fatsoma/update/hutch_1.3.1
Update to upstream 1.3.1
2 parents 448f782 + 2a9469d commit b2b2b26

17 files changed

Lines changed: 169 additions & 124 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
name: Test
22

3-
concurrency:
3+
concurrency:
44
group: ${{ github.ref }}
55
cancel-in-progress: true
66

7-
on:
8-
push:
9-
branches: [ master ]
10-
pull_request:
7+
on: [push,pull_request,workflow_dispatch]
118

129
jobs:
1310
test:
@@ -25,16 +22,15 @@ jobs:
2522
strategy:
2623
fail-fast: false
2724
matrix:
28-
ruby-version:
29-
- jruby-9.2.19.0
30-
- jruby-9.3.0.0
31-
- jruby-head
32-
- 2.7
33-
- 3.0
34-
- 3.1
25+
ruby-version:
26+
- '2.7'
27+
- '3.0'
28+
- '3.1'
29+
- '3.2'
30+
- '3.3'
3531

3632
steps:
37-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v4
3834
- name: Set up Ruby
3935
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
4036
# change this to (see https://github.com/ruby/setup-ruby#versioning):

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1+
## 1.3.2 (in development)
2+
3+
No changes yet.
4+
5+
## 1.3.1 (Dec 11, 2024)
6+
7+
### Rails 8.x Compatibility
8+
9+
Contributed by @drobny.
10+
11+
GitHub issue: [#404](https://github.com/ruby-amqp/hutch/pull/404)
12+
13+
14+
## 1.3.0 (Nov 11, 2024)
15+
16+
### Ruby 3.2 Compatibility
17+
18+
GitHub issue: [#392](https://github.com/ruby-amqp/hutch/pull/392)
19+
20+
### Relaxed ActiveSupport Dependency Constraints
21+
22+
Contributed by @drobny.
23+
24+
GitHub issue: [#402](https://github.com/ruby-amqp/hutch/pull/402)
25+
26+
### Client-Provided Connection Name
27+
28+
Contributed by @sharshenov.
29+
30+
GitHub issue: [#399](https://github.com/ruby-amqp/hutch/pull/399)
31+
32+
133
## 1.1.1 (March 18th, 2022)
34+
235
### Dependency Bump
336

437
Hutch now allows ActiveSupport 7.x.

Gemfile

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
11
source 'https://rubygems.org'
22

3-
ruby '>= 2.3.0'
3+
ruby '>= 2.7.0'
44

55
gemspec
66

77
group :development do
8-
gem 'rake'
9-
gem 'guard', '~> 2.14', platform: :mri_23
10-
gem 'guard-rspec', '~> 4.7', platform: :mri_23
8+
gem "rake"
9+
gem "guard", "~> 2.14", platform: :mri
10+
gem "guard-rspec", "~> 4.7", platform: :mri
1111

12-
gem 'yard', '~> 0.9'
13-
gem 'kramdown', '> 0', platform: :jruby
14-
gem 'redcarpet', '> 0', platform: :mri
15-
gem 'github-markup', '> 0'
12+
gem "yard", "~> 0.9"
13+
gem 'kramdown', "> 0", platform: :jruby
14+
gem "redcarpet", "> 0", platform: :mri
15+
gem "github-markup", "> 0"
1616
end
1717

1818
group :development, :test do
19-
gem 'rspec', '~> 3.5'
20-
gem 'simplecov', '~> 0.12'
19+
gem "rspec", "~> 3.12"
20+
gem "simplecov", "~> 0.21"
2121

2222
gem "sentry-raven"
2323
gem "sentry-ruby"
2424
gem "honeybadger"
25-
gem "coveralls", "~> 0.8.15", require: false
2625
gem "newrelic_rpm"
27-
gem "ddtrace", "~> 0.54.2"
28-
gem 'rspec_junit_formatter', '~> 0.3.0'
29-
gem "airbrake", "~> 10.0"
26+
gem "ddtrace", "~> 1.8"
27+
gem "airbrake", "~> 13.0"
3028
gem "rollbar"
3129
gem "bugsnag"
3230
end
3331

3432
group :development, :darwin do
35-
gem 'rb-fsevent', '~> 0.9'
36-
gem 'growl', '~> 1.0.3'
33+
gem "rb-fsevent", "~> 0.11.2"
34+
gem "growl", "~> 1.0.3"
3735
end

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ Known configuration parameters are:
435435
* `error_acknowledgements`: a chain of responsibility of objects that acknowledge/reject/requeue messages when an
436436
exception happens, see classes in `Hutch::Acknowledgements`.
437437
* `mq_exchange`: exchange to use for publishing (default: `hutch`)
438+
* `mq_client_properties`: Bunny's [client properties](https://www.rabbitmq.com/docs/connections#capabilities) (default: `{}`)
438439
* `mq_wait_exchange`: exchange to use for waiting. Leave unset to not use a wait exchange.
439440
* `mq_wait_queue`: queue to use for waiting (default: `wait-queue`)
440441
* `heartbeat`: [RabbitMQ heartbeat timeout](http://rabbitmq.com/heartbeats.html) (default: `30`)
@@ -573,6 +574,13 @@ Generate with
573574
<td><tt>HUTCH_CHANNEL_PREFETCH</tt></td>
574575
<td><p>The <tt>basic.qos</tt> prefetch value to use.</p></td>
575576
</tr>
577+
<tr>
578+
<td><tt>connection_name</tt></td>
579+
<td>nil</td>
580+
<td>String</td>
581+
<td><tt>HUTCH_CONNECTION_NAME</tt></td>
582+
<td><p><a href="https://www.rabbitmq.com/docs/connections#client-provided-names">Client-Provided Connection Name</a></p></td>
583+
</tr>
576584
<tr>
577585
<td><tt>connection_timeout</tt></td>
578586
<td>11</td>

hutch.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ require File.expand_path('../lib/hutch/version', __FILE__)
33
Gem::Specification.new do |gem|
44
if defined?(JRUBY_VERSION)
55
gem.platform = 'java'
6-
gem.add_runtime_dependency 'march_hare', '>= 3.0.0'
6+
gem.add_runtime_dependency 'march_hare', '>= 4.5.0'
77
else
88
gem.platform = Gem::Platform::RUBY
9-
gem.add_runtime_dependency 'bunny', '>= 2.19', '< 3.0'
9+
gem.add_runtime_dependency 'bunny', '>= 2.23', '< 3.0'
1010
end
1111
gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
1212
gem.add_runtime_dependency 'multi_json', '~> 1.15'
13-
gem.add_runtime_dependency 'activesupport', '>= 4.2', '< 8'
13+
gem.add_runtime_dependency 'activesupport', '>= 4.2'
1414

1515
gem.name = 'hutch'
1616
gem.summary = 'Opinionated asynchronous inter-service communication using RabbitMQ'
1717
gem.description = 'Hutch is a Ruby library for enabling asynchronous inter-service communication using RabbitMQ'
1818
gem.version = Hutch::VERSION.dup
19-
gem.required_ruby_version = '>= 2.2'
19+
gem.required_ruby_version = '>= 2.6'
2020
gem.authors = ['Harry Marr', 'Michael Klishin']
2121
gem.homepage = 'https://github.com/ruby-amqp/hutch'
2222
gem.require_paths = ['lib']

lib/hutch/broker.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'carrot-top'
44
require 'forwardable'
5+
require 'ostruct'
56
require 'hutch/logging'
67
require 'hutch/exceptions'
78
require 'hutch/publisher'
@@ -59,16 +60,16 @@ def connect(options = {})
5960
@options = options
6061
set_up_amqp_connection
6162
if http_api_use_enabled?
62-
logger.info 'HTTP API use is enabled'
63+
logger.info "HTTP API use is enabled"
6364
set_up_api_connection
6465
else
65-
logger.info 'HTTP API use is disabled'
66+
logger.info "HTTP API use is disabled"
6667
end
6768

6869
if tracing_enabled?
6970
logger.info "tracing is enabled using #{@config[:tracer]}"
7071
else
71-
logger.info 'tracing is disabled'
72+
logger.info "tracing is disabled"
7273
end
7374

7475
return unless block_given?
@@ -284,7 +285,7 @@ def api_config
284285
config.username = @config[:mq_username]
285286
config.password = @config[:mq_password]
286287
config.ssl = @config[:mq_api_ssl]
287-
config.protocol = config.ssl ? 'https://' : 'http://'
288+
config.protocol = config.ssl ? "https://" : "http://"
288289
config.sanitized_uri = "#{config.protocol}#{config.username}@#{config.host}:#{config.port}/"
289290
end
290291
end
@@ -296,6 +297,7 @@ def connection_params
296297
params[:host] = @config[:mq_host]
297298
params[:port] = @config[:mq_port]
298299
params[:vhost] = @config[:mq_vhost].presence || Hutch::Adapter::DEFAULT_VHOST
300+
params[:auth_mechanism] = @config[:mq_auth_mechanism]
299301
params[:username] = @config[:mq_username]
300302
params[:password] = @config[:mq_password]
301303
params[:tls] = @config[:mq_tls]
@@ -306,10 +308,13 @@ def connection_params
306308
params[:tls_ca_certificates] = @config[:mq_tls_ca_certificates]
307309
end
308310
params[:heartbeat] = @config[:heartbeat]
311+
params[:client_properties] = @config[:mq_client_properties]
312+
params[:connection_name] = @config[:connection_name]
309313
params[:connection_timeout] = @config[:connection_timeout]
310314
params[:read_timeout] = @config[:read_timeout]
311315
params[:write_timeout] = @config[:write_timeout]
312316

317+
313318
params[:automatically_recover] = @config[:automatically_recover]
314319
params[:network_recovery_interval] = @config[:network_recovery_interval]
315320

@@ -325,7 +330,7 @@ def parse_uri
325330
@config[:mq_tls] = u.scheme == 'amqps'
326331
@config[:mq_host] = u.host
327332
@config[:mq_port] = u.port || default_mq_port
328-
@config[:mq_vhost] = u.path.sub(%r{^/}, '')
333+
@config[:mq_vhost] = u.path.sub(/^\//, "")
329334
@config[:mq_username] = u.user
330335
@config[:mq_password] = u.password
331336
end
@@ -336,9 +341,9 @@ def default_mq_port
336341

337342
def sanitized_uri
338343
p = connection_params
339-
scheme = p[:tls] ? 'amqps' : 'amqp'
344+
scheme = p[:tls] ? "amqps" : "amqp"
340345

341-
"#{scheme}://#{p[:username]}@#{p[:host]}:#{p[:port]}/#{p[:vhost].sub(%r{^/}, '')}"
346+
"#{scheme}://#{p[:username]}@#{p[:host]}:#{p[:port]}/#{p[:vhost].sub(/^\//, '')}"
342347
end
343348

344349
def channel_work_pool

lib/hutch/config.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def self.boolean_setting(name, default_value)
6363
# RabbitMQ password
6464
string_setting :mq_password, 'guest'
6565

66+
# RabbitMQ Auth Mechanism
67+
string_setting :mq_auth_mechanism, 'PLAIN'
68+
6669
# RabbitMQ URI (takes precedence over MQ username, password, host, port and vhost settings)
6770
string_setting :uri, nil
6871

@@ -83,6 +86,9 @@ def self.boolean_setting(name, default_value)
8386
# Default: `0`, no limit. See Bunny and RabbitMQ documentation.
8487
number_setting :channel_prefetch, 0
8588

89+
# [Client-Provided Connection Name](https://www.rabbitmq.com/docs/connections#client-provided-names)
90+
string_setting :connection_name, nil
91+
8692
# Bunny's socket open timeout
8793
number_setting :connection_timeout, 11
8894

@@ -168,6 +174,7 @@ def self.initialize(params = {})
168174
# @return [Hash]
169175
def self.default_config
170176
@settings_defaults.merge({
177+
mq_client_properties: {},
171178
mq_exchange_options: {},
172179
mq_tls_cert: nil,
173180
mq_tls_key: nil,

lib/hutch/consumer.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ def self.included(base)
1313
end
1414

1515
def reject!
16+
@message_rejected = true
1617
broker.reject(delivery_info.delivery_tag)
1718
end
1819

1920
def requeue!
21+
@message_rejected = true
2022
broker.requeue(delivery_info.delivery_tag)
2123
end
2224

25+
def message_rejected?
26+
!!@message_rejected
27+
end
28+
2329
def logger
2430
Hutch::Logging.logger
2531
end

lib/hutch/tracers/datadog.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'ddtrace'
2+
require 'ddtrace/auto_instrument'
23

34
module Hutch
45
module Tracers
@@ -8,7 +9,7 @@ def initialize(klass)
89
end
910

1011
def handle(message)
11-
::Datadog.tracer.trace(@klass.class.name, service: 'hutch', span_type: 'rabbitmq') do
12+
::Datadog::Tracing.trace(@klass.class.name, continue_from: nil, service: 'hutch', type: 'rabbitmq') do
1213
@klass.process(message)
1314
end
1415
end

0 commit comments

Comments
 (0)