hutch 1.1.0 → 1.1.1

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: 74721c392b797963bf268ff65d638b888e11d43307446ed63bd3de14e36aa97e
4
- data.tar.gz: 1ddb6053bd164c0332650169415ae9a20daa9724039be7765cc90aade1e0f304
3
+ metadata.gz: 9725ddb3e39e305bad95abd6c8605c1d9828691904bb2ae31430fd22d88bd180
4
+ data.tar.gz: db1d87d81de0f89c84b1ec387c66443aa9ead6be2d71b50b6cee32e9146dd080
5
5
  SHA512:
6
- metadata.gz: e690481212eeca9499f491b34c39e9f8e4f883f617063a5123bf1471e87b7f7251c52e0c92b103fe73dfa8db1859ad5feca76b6f0694ff68554191e66621f209
7
- data.tar.gz: 043c203877a230f2d50c023a005ce84c7a7fc764c2b6ce3d452ab8aa143fa4175e4ba4bd54a4e2e611839360b2ec292d28c03ec338c92bbaa3b84e34b8a644f0
6
+ metadata.gz: 296138c5cb4c08340f4a72bb8d30009402272f9843efffd0dc1d647328ca1531d188fd3b5a9a15f891f4a8447dbf5f72a7a583aa702f1c999fc557c1ab4ac024
7
+ data.tar.gz: 2c0406261d2535d5e5d00037e20e29f5cb781e337732491cf36195231e5d647b75c0d96d74c0861afa36cfb24575a0e2b34ce06f59693a98b84342cf1d52ad95
@@ -0,0 +1,42 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ services:
15
+ rabbitmq:
16
+ image: rabbitmq:3-management
17
+ ports:
18
+ - 5672:5672
19
+ - 15672:15672
20
+ options: --name rabbitmq
21
+
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ ruby-version: ['jruby-9.2.19.0', 'jruby-9.3.0.0', 'jruby-head']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v2
29
+ - name: Set up Ruby
30
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
+ uses: ruby/setup-ruby@v1
33
+ # uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
34
+ with:
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
+ - name: Set up RabbitMQ
38
+ run: |
39
+ until sudo lsof -i:5672; do echo "Waiting for RabbitMQ to start..."; sleep 1; done
40
+ ./bin/ci/before_build_docker.sh
41
+ - name: Run tests
42
+ run: bundle exec rspec spec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.1.1 (March 18th, 2022)
2
+ ### Dependency Bump
3
+
4
+ Hutch now allows ActiveSupport 7.x.
5
+
6
+
1
7
  ## 1.1.0 (July 26th, 2021)
2
8
 
3
9
  ### Bugsnag Error Handler
@@ -6,13 +12,18 @@ Contributed by @ivanhuang1.
6
12
 
7
13
  GitHub issue: [#362](https://github.com/ruby-amqp/hutch/pull/362)
8
14
 
15
+ ### Datadog Tracer
16
+
17
+ Contributed by Karol @Azdaroth Galanciak.
18
+
19
+ GitHub issue: [#360](https://github.com/ruby-amqp/hutch/pull/360)
20
+
9
21
  ### Updated Sentry Error Handler
10
22
 
11
23
  Contributed by Karol @Azdaroth Galanciak.
12
24
 
13
25
  GitHub issue: [#363](https://github.com/ruby-amqp/hutch/pull/363)
14
26
 
15
-
16
27
  ### Type Casting for Values Set Using Hutch::Config.set
17
28
 
18
29
  Values set with `Hutch::Config.set` now have expected setting type casting
@@ -22,6 +33,17 @@ Contributed by Karol @Azdaroth Galanciak.
22
33
 
23
34
  GitHub issue: [#358](https://github.com/ruby-amqp/hutch/pull/358)
24
35
 
36
+ ### Wider MultiJson Adoption
37
+
38
+ Contributed by Ulysse @BuonOmo Buonomo.
39
+
40
+ GitHub issue: [#356](https://github.com/ruby-amqp/hutch/pull/356)
41
+
42
+ ### README Corrections
43
+
44
+ Contributed by Johan @johankok Kok.
45
+
46
+ GitHub issue: [#353](https://github.com/ruby-amqp/hutch/pull/353)
25
47
 
26
48
  ## 1.0.0 (April 8th, 2020)
27
49
 
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2013-2016 GoCardless
2
- Copyright (c) 2016-2020 Hutch contributors
2
+ Copyright (c) 2016-2021 Hutch contributors
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  ![](http://cl.ly/image/3h0q3F3G142K/hutch.png)
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/hutch.svg)](http://badge.fury.io/rb/hutch)
4
- [![Build Status](https://travis-ci.org/gocardless/hutch.svg?branch=master)](https://travis-ci.org/gocardless/hutch)
5
4
  [![Code Climate](https://codeclimate.com/github/gocardless/hutch.svg)](https://codeclimate.com/github/gocardless/hutch)
6
5
 
7
6
  Hutch is a Ruby library for enabling asynchronous inter-service communication
@@ -0,0 +1,20 @@
1
+ #!/bin/sh
2
+
3
+ CTL=${MARCH_HARE_RABBITMQCTL:="docker exec rabbitmq rabbitmqctl"}
4
+ PLUGINS=${MARCH_HARE_RABBITMQ_PLUGINS:="docker exec rabbitmq rabbitmq-plugins"}
5
+
6
+ $PLUGINS enable rabbitmq_management
7
+
8
+ sleep 3
9
+
10
+ # guest:guest has full access to /
11
+
12
+ $CTL add_vhost /
13
+ # $CTL add_user guest guest # already exists
14
+ $CTL set_permissions -p / guest ".*" ".*" ".*"
15
+
16
+ # Reduce retention policy for faster publishing of stats
17
+ $CTL eval 'supervisor2:terminate_child(rabbit_mgmt_sup_sup, rabbit_mgmt_sup), application:set_env(rabbitmq_management, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_sup_sup:start_child().'
18
+ $CTL eval 'supervisor2:terminate_child(rabbit_mgmt_agent_sup_sup, rabbit_mgmt_agent_sup), application:set_env(rabbitmq_management_agent, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_agent_sup_sup:start_child().'
19
+
20
+ sleep 3
data/hutch.gemspec CHANGED
@@ -6,21 +6,19 @@ Gem::Specification.new do |gem|
6
6
  gem.add_runtime_dependency 'march_hare', '>= 3.0.0'
7
7
  else
8
8
  gem.platform = Gem::Platform::RUBY
9
- gem.add_runtime_dependency 'bunny', '>= 2.16', '< 3.0'
9
+ gem.add_runtime_dependency 'bunny', '>= 2.19', '< 3.0'
10
10
  end
11
11
  gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
12
- gem.add_runtime_dependency 'multi_json', '~> 1.14'
13
- gem.add_runtime_dependency 'activesupport', '>= 4.2', '< 7'
12
+ gem.add_runtime_dependency 'multi_json', '~> 1.15'
13
+ gem.add_runtime_dependency 'activesupport', '>= 4.2', '< 8'
14
14
 
15
15
  gem.name = 'hutch'
16
- gem.summary = 'Easy inter-service communication using RabbitMQ.'
17
- gem.description = 'Hutch is a Ruby library for enabling asynchronous ' \
18
- 'inter-service communication using RabbitMQ.'
16
+ gem.summary = 'Opinionated asynchronous inter-service communication using RabbitMQ'
17
+ gem.description = 'Hutch is a Ruby library for enabling asynchronous inter-service communication using RabbitMQ'
19
18
  gem.version = Hutch::VERSION.dup
20
19
  gem.required_ruby_version = '>= 2.2'
21
- gem.authors = ['Harry Marr']
22
- gem.email = ['developers@gocardless.com']
23
- gem.homepage = 'https://github.com/gocardless/hutch'
20
+ gem.authors = ['Harry Marr', 'Michael Klishin']
21
+ gem.homepage = 'https://github.com/ruby-amqp/hutch'
24
22
  gem.require_paths = ['lib']
25
23
  gem.license = 'MIT'
26
24
  gem.executables = ['hutch']
@@ -28,6 +28,10 @@ module Hutch
28
28
  def current_timestamp
29
29
  Time.now.to_i
30
30
  end
31
+
32
+ def self.new_exchange(ch, exchange_type, exchange_name, exchange_options)
33
+ Bunny::Exchange.new(ch, exchange_type, exchange_name, exchange_options)
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -32,6 +32,10 @@ module Hutch
32
32
  def current_timestamp
33
33
  Time.now
34
34
  end
35
+
36
+ def self.new_exchange(ch, exchange_type, exchange_name, exchange_options)
37
+ MarchHare::Exchange.new(ch, exchange_name, exchange_options.merge(type: exchange_type))
38
+ end
35
39
  end
36
40
  end
37
41
  end
data/lib/hutch/broker.rb CHANGED
@@ -127,7 +127,7 @@ module Hutch
127
127
  logger.info "using topic exchange '#{exchange_name}'"
128
128
 
129
129
  with_bunny_precondition_handler('exchange') do
130
- Bunny::Exchange.new(ch, exchange_type, exchange_name, exchange_options)
130
+ Adapter.new_exchange(ch, exchange_type, exchange_name, exchange_options)
131
131
  end
132
132
  end
133
133
 
@@ -171,11 +171,11 @@ module Hutch
171
171
  end
172
172
 
173
173
  # Create / get a durable queue and apply namespace if it exists.
174
- def queue(name, arguments = {})
174
+ def queue(name, options = {})
175
175
  with_bunny_precondition_handler('queue') do
176
176
  namespace = @config[:namespace].to_s.downcase.gsub(/[^-_:\.\w]/, "")
177
177
  name = name.prepend(namespace + ":") if namespace.present?
178
- channel.queue(name, durable: true, arguments: arguments)
178
+ channel.queue(name, **options)
179
179
  end
180
180
  end
181
181
 
@@ -65,6 +65,11 @@ module Hutch
65
65
  @arguments = arguments
66
66
  end
67
67
 
68
+ # Congfiures queue options that will be passed when declaring the queue.
69
+ def queue_options(options = {})
70
+ @queue_options = options
71
+ end
72
+
68
73
  # Set custom serializer class, override global value
69
74
  def serializer(name)
70
75
  @serializer = name
@@ -91,6 +96,15 @@ module Hutch
91
96
  all_arguments
92
97
  end
93
98
 
99
+ def get_options
100
+ default_options = { durable: true }
101
+
102
+ all_options = default_options.merge(@queue_options || {})
103
+ all_options[:arguments] = get_arguments
104
+
105
+ all_options
106
+ end
107
+
94
108
  # Accessor for the consumer's routing key.
95
109
  def routing_keys
96
110
  @routing_keys ||= Set.new
data/lib/hutch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hutch
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
data/lib/hutch/worker.rb CHANGED
@@ -47,7 +47,7 @@ module Hutch
47
47
  def setup_queue(consumer)
48
48
  logger.info "setting up queue: #{consumer.get_queue_name}"
49
49
 
50
- queue = @broker.queue(consumer.get_queue_name, consumer.get_arguments)
50
+ queue = @broker.queue(consumer.get_queue_name, consumer.get_options)
51
51
  @broker.bind_queue(queue, consumer.routing_keys)
52
52
 
53
53
  queue.subscribe(consumer_tag: unique_consumer_tag, manual_ack: true) do |*args|
@@ -262,7 +262,7 @@ describe Hutch::Broker do
262
262
  args.first == ''
263
263
  args.last == arguments
264
264
  end
265
- broker.queue('test', arguments)
265
+ broker.queue('test', arguments: arguments)
266
266
  end
267
267
  end
268
268
 
@@ -4,7 +4,7 @@ require 'hutch/worker'
4
4
  describe Hutch::Worker do
5
5
  let(:consumer) { double('Consumer', routing_keys: %w( a b c ),
6
6
  get_queue_name: 'consumer', get_arguments: {},
7
- get_serializer: nil) }
7
+ get_options: {}, get_serializer: nil) }
8
8
  let(:consumers) { [consumer, double('Consumer')] }
9
9
  let(:broker) { Hutch::Broker.new }
10
10
  let(:setup_procs) { Array.new(2) { Proc.new {} } }
@@ -35,7 +35,7 @@ describe Hutch::Worker do
35
35
  before { allow(broker).to receive_messages(queue: queue, bind_queue: nil) }
36
36
 
37
37
  it 'creates a queue' do
38
- expect(broker).to receive(:queue).with(consumer.get_queue_name, consumer.get_arguments).and_return(queue)
38
+ expect(broker).to receive(:queue).with(consumer.get_queue_name, consumer.get_options).and_return(queue)
39
39
  worker.setup_queue(consumer)
40
40
  end
41
41
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hutch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Marr
8
+ - Michael Klishin
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2021-07-26 00:00:00.000000000 Z
12
+ date: 2022-03-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bunny
@@ -16,7 +17,7 @@ dependencies:
16
17
  requirements:
17
18
  - - ">="
18
19
  - !ruby/object:Gem::Version
19
- version: '2.16'
20
+ version: '2.19'
20
21
  - - "<"
21
22
  - !ruby/object:Gem::Version
22
23
  version: '3.0'
@@ -26,7 +27,7 @@ dependencies:
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
29
- version: '2.16'
30
+ version: '2.19'
30
31
  - - "<"
31
32
  - !ruby/object:Gem::Version
32
33
  version: '3.0'
@@ -50,14 +51,14 @@ dependencies:
50
51
  requirements:
51
52
  - - "~>"
52
53
  - !ruby/object:Gem::Version
53
- version: '1.14'
54
+ version: '1.15'
54
55
  type: :runtime
55
56
  prerelease: false
56
57
  version_requirements: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - "~>"
59
60
  - !ruby/object:Gem::Version
60
- version: '1.14'
61
+ version: '1.15'
61
62
  - !ruby/object:Gem::Dependency
62
63
  name: activesupport
63
64
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +68,7 @@ dependencies:
67
68
  version: '4.2'
68
69
  - - "<"
69
70
  - !ruby/object:Gem::Version
70
- version: '7'
71
+ version: '8'
71
72
  type: :runtime
72
73
  prerelease: false
73
74
  version_requirements: !ruby/object:Gem::Requirement
@@ -77,19 +78,18 @@ dependencies:
77
78
  version: '4.2'
78
79
  - - "<"
79
80
  - !ruby/object:Gem::Version
80
- version: '7'
81
+ version: '8'
81
82
  description: Hutch is a Ruby library for enabling asynchronous inter-service communication
82
- using RabbitMQ.
83
+ using RabbitMQ
83
84
  email:
84
- - developers@gocardless.com
85
85
  executables:
86
86
  - hutch
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/test.yml"
90
91
  - ".gitignore"
91
92
  - ".rspec"
92
- - ".travis.yml"
93
93
  - ".yardopts"
94
94
  - CHANGELOG.md
95
95
  - Gemfile
@@ -98,6 +98,7 @@ files:
98
98
  - README.md
99
99
  - Rakefile
100
100
  - bin/ci/before_build.sh
101
+ - bin/ci/before_build_docker.sh
101
102
  - bin/ci/install_on_debian.sh
102
103
  - bin/hutch
103
104
  - examples/consumer.rb
@@ -165,7 +166,7 @@ files:
165
166
  - templates/default/method_details/text/settings.erb
166
167
  - templates/default/module/html/settings.erb
167
168
  - templates/default/module/setup.rb
168
- homepage: https://github.com/gocardless/hutch
169
+ homepage: https://github.com/ruby-amqp/hutch
169
170
  licenses:
170
171
  - MIT
171
172
  metadata: {}
@@ -187,7 +188,7 @@ requirements: []
187
188
  rubygems_version: 3.1.4
188
189
  signing_key:
189
190
  specification_version: 4
190
- summary: Easy inter-service communication using RabbitMQ.
191
+ summary: Opinionated asynchronous inter-service communication using RabbitMQ
191
192
  test_files:
192
193
  - spec/hutch/broker_spec.rb
193
194
  - spec/hutch/cli_spec.rb
data/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- dist: bionic
2
- sudo: required
3
-
4
- language: ruby
5
- cache: bundler
6
- before_install:
7
- - gem install bundler
8
- before_script:
9
- - "./bin/ci/install_on_debian.sh"
10
- - until sudo lsof -i:5672; do echo "Waiting for RabbitMQ to start..."; sleep 1; done
11
- - "./bin/ci/before_build.sh"
12
- matrix:
13
- include:
14
- - rvm: "3.0.0"
15
- - rvm: "2.7.1"
16
- - rvm: "2.6.6"
17
- - rvm: "2.5.8"
18
- - rvm: "jruby-9.2.19.0"
19
- name: "Latest JRuby"
20
- - rvm: "ruby-head"
21
- allow_failures:
22
- - name: "Latest JRuby"
23
- - rvm: ruby-head