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 +4 -4
- data/.github/workflows/test.yml +42 -0
- data/CHANGELOG.md +23 -1
- data/LICENSE +1 -1
- data/README.md +0 -1
- data/bin/ci/before_build_docker.sh +20 -0
- data/hutch.gemspec +7 -9
- data/lib/hutch/adapters/bunny.rb +4 -0
- data/lib/hutch/adapters/march_hare.rb +4 -0
- data/lib/hutch/broker.rb +3 -3
- data/lib/hutch/consumer.rb +14 -0
- data/lib/hutch/version.rb +1 -1
- data/lib/hutch/worker.rb +1 -1
- data/spec/hutch/broker_spec.rb +1 -1
- data/spec/hutch/worker_spec.rb +2 -2
- metadata +14 -13
- data/.travis.yml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9725ddb3e39e305bad95abd6c8605c1d9828691904bb2ae31430fd22d88bd180
|
4
|
+
data.tar.gz: db1d87d81de0f89c84b1ec387c66443aa9ead6be2d71b50b6cee32e9146dd080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
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.
|
13
|
-
gem.add_runtime_dependency 'activesupport', '>= 4.2', '<
|
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 = '
|
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.
|
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']
|
data/lib/hutch/adapters/bunny.rb
CHANGED
@@ -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
|
-
|
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,
|
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,
|
178
|
+
channel.queue(name, **options)
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
data/lib/hutch/consumer.rb
CHANGED
@@ -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
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.
|
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|
|
data/spec/hutch/broker_spec.rb
CHANGED
data/spec/hutch/worker_spec.rb
CHANGED
@@ -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.
|
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.
|
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:
|
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.
|
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.
|
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.
|
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.
|
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: '
|
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: '
|
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/
|
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:
|
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
|