msgr 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +8 -0
- data/.github/workflows/test.yml +79 -0
- data/.rubocop.yml +12 -47
- data/Appraisals +23 -0
- data/CHANGELOG.md +87 -5
- data/Gemfile +9 -15
- data/README.md +11 -28
- data/Rakefile +10 -6
- data/bin/msgr +1 -0
- data/gemfiles/rails_5.2.gemfile +15 -0
- data/gemfiles/rails_6.0.gemfile +15 -0
- data/gemfiles/rails_6.1.gemfile +15 -0
- data/gemfiles/rails_7.0.gemfile +15 -0
- data/gemfiles/rails_head.gemfile +15 -0
- data/lib/msgr/binding.rb +13 -8
- data/lib/msgr/channel.rb +7 -10
- data/lib/msgr/cli.rb +26 -20
- data/lib/msgr/client.rb +27 -25
- data/lib/msgr/connection.rb +14 -2
- data/lib/msgr/consumer.rb +2 -3
- data/lib/msgr/dispatcher.rb +7 -9
- data/lib/msgr/logging.rb +2 -0
- data/lib/msgr/message.rb +1 -2
- data/lib/msgr/railtie.rb +14 -75
- data/lib/msgr/route.rb +2 -5
- data/lib/msgr/routes.rb +2 -0
- data/lib/msgr/tasks/msgr/drain.rake +11 -0
- data/lib/msgr/test_pool.rb +1 -3
- data/lib/msgr/version.rb +1 -1
- data/lib/msgr.rb +2 -3
- data/msgr.gemspec +8 -6
- data/renovate.json +5 -0
- data/scripts/simple_test.rb +3 -4
- data/spec/fixtures/{msgr-routes-test-1.rb → msgr_routes_test_1.rb} +0 -0
- data/spec/fixtures/msgr_routes_test_drain.rb +5 -0
- data/spec/integration/dummy/Rakefile +1 -1
- data/spec/{msgr/support/.keep → integration/dummy/app/assets/config/manifest.js} +0 -0
- data/spec/integration/dummy/bin/bundle +1 -1
- data/spec/integration/dummy/bin/rails +1 -1
- data/spec/integration/dummy/config/application.rb +1 -1
- data/spec/integration/dummy/config/boot.rb +2 -2
- data/spec/integration/dummy/config/environment.rb +1 -1
- data/spec/integration/dummy/config/rabbitmq.yml +1 -1
- data/spec/integration/msgr/dispatcher_spec.rb +28 -12
- data/spec/integration/msgr/railtie_spec.rb +10 -120
- data/spec/integration/spec_helper.rb +2 -3
- data/spec/integration/{msgr_spec.rb → test_controller_spec.rb} +1 -1
- data/spec/unit/msgr/client_spec.rb +83 -0
- data/spec/{msgr → unit}/msgr/connection_spec.rb +1 -1
- data/spec/{msgr → unit}/msgr/consumer_spec.rb +0 -0
- data/spec/unit/msgr/dispatcher_spec.rb +45 -0
- data/spec/{msgr → unit}/msgr/route_spec.rb +29 -14
- data/spec/{msgr → unit}/msgr/routes_spec.rb +32 -35
- data/spec/{msgr → unit}/msgr_spec.rb +26 -18
- data/spec/{msgr → unit}/spec_helper.rb +1 -1
- data/spec/unit/support/.keep +0 -0
- metadata +43 -36
- data/.travis.yml +0 -43
- data/gemfiles/Gemfile.rails-4-2 +0 -7
- data/gemfiles/Gemfile.rails-5-0 +0 -7
- data/gemfiles/Gemfile.rails-5-1 +0 -7
- data/gemfiles/Gemfile.rails-5-2 +0 -7
- data/gemfiles/Gemfile.rails-master +0 -14
- data/spec/msgr/msgr/client_spec.rb +0 -60
- data/spec/msgr/msgr/dispatcher_spec.rb +0 -44
- data/spec/support/setup.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1d1c4c93abd233370b3175719c7d41902637c1d8cae51223f86f3cd16611da9
|
4
|
+
data.tar.gz: 432388472168160b0bc1be0ee303656ab0776674d3178ac63f6c375a7395fb6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11ce36e23b4a499aaaff01e67a1be9a91048e19e9c55cf0487491aef49d3343d1ead2cb854e4c1a1035319e524b764f62c4846e6632bac5fa81da9b7fb125329
|
7
|
+
data.tar.gz: 62e2a4460070ae90fe264f270cab8852f81d85f177e2fe77e8b730926f88a11dd651506cc1b5ef58fafefa3b23c1ea0889239beacd7ba6b8342d04d65e11e05c
|
data/.editorconfig
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
name: test
|
2
|
+
on: [push]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
|
6
|
+
runs-on: ubuntu-20.04
|
7
|
+
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby:
|
11
|
+
- "3.0"
|
12
|
+
- "2.7"
|
13
|
+
- "2.6"
|
14
|
+
- "2.5"
|
15
|
+
gemfile:
|
16
|
+
- rails_5.2.gemfile
|
17
|
+
- rails_6.0.gemfile
|
18
|
+
- rails_6.1.gemfile
|
19
|
+
- rails_7.0.gemfile
|
20
|
+
exclude:
|
21
|
+
- ruby: "3.0"
|
22
|
+
gemfile: rails_5.2.gemfile
|
23
|
+
- ruby: "2.5"
|
24
|
+
gemfile: rails_7.0.gemfile
|
25
|
+
- ruby: "2.6"
|
26
|
+
gemfile: rails_7.0.gemfile
|
27
|
+
fail-fast: False
|
28
|
+
|
29
|
+
services:
|
30
|
+
rabbitmq:
|
31
|
+
image: rabbitmq:latest
|
32
|
+
options: >-
|
33
|
+
--health-cmd "rabbitmqctl node_health_check"
|
34
|
+
--health-interval 10s
|
35
|
+
--health-timeout 5s
|
36
|
+
--health-retries 5
|
37
|
+
ports:
|
38
|
+
- 5672:5672
|
39
|
+
|
40
|
+
env:
|
41
|
+
AMQP_SERVER: amqp://localhost:5672
|
42
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
|
43
|
+
BUNDLE_JOBS: 4
|
44
|
+
BUNDLE_RETRY: 10
|
45
|
+
BUNDLE_WITHOUT: development
|
46
|
+
|
47
|
+
steps:
|
48
|
+
- uses: actions/checkout@master
|
49
|
+
|
50
|
+
- name: Setup Ruby
|
51
|
+
uses: ruby/setup-ruby@v1
|
52
|
+
with:
|
53
|
+
ruby-version: ${{ matrix.ruby }}
|
54
|
+
bundler-cache: True
|
55
|
+
|
56
|
+
- name: Run unit tests
|
57
|
+
run: bundle exec rspec -Ispec/unit --color spec/unit
|
58
|
+
|
59
|
+
- name: Run integration tests
|
60
|
+
run: bundle exec rspec -Ispec/integration --color spec/integration
|
61
|
+
|
62
|
+
rubocop:
|
63
|
+
name: rubocop
|
64
|
+
runs-on: ubuntu-20.04
|
65
|
+
|
66
|
+
env:
|
67
|
+
BUNDLE_JOBS: 4
|
68
|
+
BUNDLE_RETRY: 10
|
69
|
+
BUNDLE_WITHOUT: development
|
70
|
+
|
71
|
+
steps:
|
72
|
+
- uses: actions/checkout@master
|
73
|
+
- uses: ruby/setup-ruby@v1
|
74
|
+
with:
|
75
|
+
ruby-version: 3.0
|
76
|
+
bundler-cache: true
|
77
|
+
|
78
|
+
- name: Run rubocop
|
79
|
+
run: bundle exec rubocop --parallel --color
|
data/.rubocop.yml
CHANGED
@@ -1,52 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
inherit_gem:
|
2
|
+
my-rubocop: default.yml
|
4
3
|
|
5
|
-
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.5
|
6
|
+
SuggestExtensions: False
|
6
7
|
Exclude:
|
7
|
-
-
|
8
|
+
- gemfiles/**/*
|
9
|
+
- spec/integration/dummy/**/*
|
10
|
+
- vendor/**/*
|
8
11
|
|
9
|
-
|
12
|
+
Layout/LineLength:
|
10
13
|
Exclude:
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
Layout/AlignParameters:
|
15
|
-
EnforcedStyle: with_fixed_indentation
|
16
|
-
|
17
|
-
Layout/CaseIndentation:
|
18
|
-
EnforcedStyle: end
|
19
|
-
SupportedStyles:
|
20
|
-
- case
|
21
|
-
- end
|
22
|
-
IndentOneStep: true
|
23
|
-
|
24
|
-
Layout/SpaceInsideBlockBraces:
|
25
|
-
EnforcedStyle: space
|
26
|
-
EnforcedStyleForEmptyBraces: no_space
|
27
|
-
SpaceBeforeBlockParameters: false
|
28
|
-
|
29
|
-
Layout/SpaceInsideHashLiteralBraces:
|
30
|
-
EnforcedStyle: no_space
|
31
|
-
|
32
|
-
|
33
|
-
Style/BracesAroundHashParameters:
|
34
|
-
EnforcedStyle: context_dependent
|
35
|
-
|
36
|
-
Style/ClassAndModuleChildren:
|
37
|
-
Enabled: false
|
38
|
-
|
39
|
-
Style/Documentation:
|
40
|
-
Enabled: false
|
41
|
-
|
42
|
-
Style/RaiseArgs:
|
43
|
-
EnforcedStyle: compact
|
44
|
-
|
45
|
-
Style/SafeNavigation:
|
46
|
-
Enabled: false # not available before 2.3
|
47
|
-
|
48
|
-
Style/SignalException:
|
49
|
-
EnforcedStyle: only_raise
|
14
|
+
- spec/**/*
|
50
15
|
|
51
|
-
|
52
|
-
|
16
|
+
RSpec/MultipleMemoizedHelpers:
|
17
|
+
Max: 15
|
data/Appraisals
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# vim: ft=ruby
|
4
|
+
|
5
|
+
appraise 'rails-5.2' do
|
6
|
+
gem 'rails', '~> 5.2.0'
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise 'rails-6.0' do
|
10
|
+
gem 'rails', '~> 6.0.0'
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise 'rails-6.1' do
|
14
|
+
gem 'rails', '~> 6.1.0'
|
15
|
+
end
|
16
|
+
|
17
|
+
appraise 'rails-7.0' do
|
18
|
+
gem 'rails', '~> 6.1.0'
|
19
|
+
end
|
20
|
+
|
21
|
+
appraise 'rails-head' do
|
22
|
+
gem 'rails', git: 'https://github.com/rails/rails', require: 'rails'
|
23
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,37 +1,85 @@
|
|
1
1
|
# Changelog
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file.
|
3
4
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
5
6
|
|
6
7
|
## [Unreleased]
|
7
8
|
|
9
|
+
## [1.4.0] - 2022-01-10
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Support for namespaced consumer classes in routes file (#48, #49)
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
|
17
|
+
- Unused `Channel#reject` method
|
18
|
+
|
19
|
+
## [1.3.2] - 2021-09-21
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
|
23
|
+
- Rake task `msgr:drain` ran before all routes were initialized (#44)
|
24
|
+
|
25
|
+
## [1.3.1] - 2020-12-16
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
|
29
|
+
- Delay setting default options for correct relative routing file path
|
30
|
+
|
31
|
+
## [1.3.0] - 2020-12-16
|
32
|
+
|
33
|
+
### Added
|
34
|
+
|
35
|
+
- Support and testing for Rails 6.1
|
36
|
+
- Rake task for purging all known queues (#43)
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- High-risk feature to autostart client in-process has been removed without replacement
|
41
|
+
- Parsing config is more relaxed now but directly based on YAML boolean values
|
42
|
+
|
8
43
|
## [1.2.0] - 2019-06-27
|
44
|
+
|
9
45
|
### Added
|
46
|
+
|
10
47
|
- Test support of Rails 5.2
|
11
48
|
|
12
49
|
### Changed
|
50
|
+
|
13
51
|
- Serialize JSON using core JSON instead of MultiJson
|
14
52
|
- Remove application/text fallback for payload (#25)
|
15
53
|
|
16
54
|
## [1.1.0] - 2018-07-25
|
55
|
+
|
17
56
|
### Added
|
57
|
+
|
18
58
|
- New command line runner
|
19
59
|
|
20
60
|
## [1.0.0] - 2017-12-29
|
61
|
+
|
21
62
|
### Changed
|
63
|
+
|
22
64
|
- Configure prefetch per binding and disable auto ack in consumer for customized batch processing (#15)
|
23
65
|
- Replace usage of deprecated exception class (#12)
|
24
66
|
|
25
67
|
## [0.15.2] - 2017-09-04
|
68
|
+
|
26
69
|
### Fixed
|
70
|
+
|
27
71
|
- Fix regression in parsing `:uri` config with empty path
|
28
72
|
|
29
73
|
## [0.15.1] - 2017-07-31
|
74
|
+
|
30
75
|
### Fixed
|
76
|
+
|
31
77
|
- Fix errors with additional configuration keys for AMQP connection (#13)
|
32
78
|
|
33
79
|
## [0.15.0] - 2017-03-30
|
80
|
+
|
34
81
|
### Added
|
82
|
+
|
35
83
|
- Add new configuration option `:raise_exceptions` that can be used to enable
|
36
84
|
exceptions being raised from consumers. Mostly useful for testing consumers.
|
37
85
|
Defaults to `false`.
|
@@ -39,69 +87,103 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
39
87
|
- Add methods for purging queues
|
40
88
|
|
41
89
|
### Changed
|
90
|
+
|
42
91
|
- Rework TestPool timeout handling to not account processing time
|
43
92
|
|
44
93
|
## [0.14.1] - 2016-02-17
|
94
|
+
|
45
95
|
### Fixed
|
96
|
+
|
46
97
|
- Fix loading test pool source file
|
47
98
|
|
48
99
|
## [0.14.0] - 2016-02-17
|
100
|
+
|
49
101
|
### Added
|
102
|
+
|
50
103
|
- Add experimental test pool (`Msgr::TestPool`)
|
51
104
|
|
52
105
|
## [0.13.0] - 2015-08-24
|
106
|
+
|
53
107
|
### Changed
|
108
|
+
|
54
109
|
- Use `Rails.application.config_for` if available.
|
55
110
|
|
56
111
|
## [0.12.2] - 2015-01-14
|
112
|
+
|
57
113
|
### Changed
|
114
|
+
|
58
115
|
- Do not delete the exchange on stop delete:true - as the exchange is changed
|
59
116
|
|
60
117
|
## [0.12.1] - 2014-11-06
|
118
|
+
|
61
119
|
### Changed
|
120
|
+
|
62
121
|
- Loose dependency on bunny to allow `~> 1.4` for stone-age old RabbitMQ servers.
|
63
122
|
|
64
123
|
## [0.11.0-rc3] - 2014-04-11
|
124
|
+
|
65
125
|
### Added
|
126
|
+
|
66
127
|
- Add checkcredentials config option to disable initial connect to rabbitmq
|
67
128
|
server to check the credentials
|
68
129
|
|
69
130
|
### Changed
|
131
|
+
|
70
132
|
- Define pool_class by string to make it useable with rails
|
71
133
|
|
72
134
|
## [0.11.0-rc2] - 2014-03-29
|
135
|
+
|
73
136
|
### Added
|
137
|
+
|
74
138
|
- Add nack for messages when an error is rescued by dispatcher
|
75
139
|
|
76
140
|
## [0.11.0-rc1] - 2014-03-29
|
141
|
+
|
77
142
|
### Added
|
143
|
+
|
78
144
|
- Add pool_class config to override pool classes used by dispatcher
|
79
145
|
|
80
146
|
## [0.4.1] - 2014-03-18
|
147
|
+
|
81
148
|
### Fixed
|
82
|
-
- Fix bug with empty routes on client start
|
83
149
|
|
84
|
-
|
85
|
-
### Changed
|
86
|
-
- Some lost history due to several crises
|
150
|
+
- Fix bug with empty routes on client start
|
87
151
|
|
88
152
|
## [0.4.0] - 2014-03-04
|
153
|
+
|
89
154
|
### Changed
|
155
|
+
|
90
156
|
- Improve railtie and autostart code
|
91
157
|
|
158
|
+
## 0.4.0 - 0.10.0
|
159
|
+
|
160
|
+
### Changed
|
161
|
+
|
162
|
+
- Some lost history due to several crises
|
163
|
+
|
92
164
|
## [0.3.0] - 2014-03-03
|
165
|
+
|
93
166
|
### Added
|
167
|
+
|
94
168
|
- Support for forking web servers like unicorn
|
95
169
|
|
96
170
|
## [0.2.1] - 2014-02-26
|
171
|
+
|
97
172
|
### Fixed
|
173
|
+
|
98
174
|
- Fix wrong rails initializer code - was not use the config file
|
99
175
|
|
100
176
|
## [0.2.0] - 2014-02-21
|
177
|
+
|
101
178
|
### Changed
|
179
|
+
|
102
180
|
- Improve rails initializer code
|
103
181
|
|
104
|
-
[
|
182
|
+
[unreleased]: https://github.com/jgraichen/msgr/compare/v1.4.0...HEAD
|
183
|
+
[1.4.0]: https://github.com/jgraichen/msgr/compare/v1.3.2...v1.4.0
|
184
|
+
[1.3.2]: https://github.com/jgraichen/msgr/compare/v1.3.1...v1.3.2
|
185
|
+
[1.3.1]: https://github.com/jgraichen/msgr/compare/v1.3.0...v1.3.1
|
186
|
+
[1.3.0]: https://github.com/jgraichen/msgr/compare/v1.2.0...v1.3.0
|
105
187
|
[1.2.0]: https://github.com/jgraichen/msgr/compare/v1.1.0...v1.2.0
|
106
188
|
[1.1.0]: https://github.com/jgraichen/msgr/compare/v1.0.0...v1.1.0
|
107
189
|
[1.0.0]: https://github.com/jgraichen/msgr/compare/v0.15.2...v1.0.0
|
data/Gemfile
CHANGED
@@ -2,22 +2,16 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
gem 'appraisal'
|
6
|
+
gem 'coveralls'
|
7
|
+
gem 'my-rubocop', github: 'jgraichen/my-rubocop', ref: 'v4'
|
8
|
+
gem 'rake'
|
9
|
+
gem 'rake-release', '~> 1.1'
|
10
|
+
gem 'rspec', '~> 3.0'
|
11
|
+
gem 'rspec-rails'
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
gem 'rails', '>= 4.2'
|
16
|
-
gem 'sqlite3', '~> 1.3.6'
|
17
|
-
end
|
18
|
-
|
19
|
-
gem 'rspec-rails', require: false
|
20
|
-
end
|
13
|
+
gem 'rails'
|
14
|
+
gem 'sqlite3'
|
21
15
|
|
22
16
|
# Specify your gem's dependencies in acfs.gemspec
|
23
17
|
gemspec
|
data/README.md
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
# Msgr:
|
1
|
+
# Msgr: _Rails-like Messaging Framework_
|
2
2
|
|
3
|
-
|
4
|
-
[![
|
5
|
-
[![Build Status](http://img.shields.io/travis/jgraichen/msgr/master.svg)](https://travis-ci.org/jgraichen/msgr)
|
6
|
-
[![Coverage Status](http://img.shields.io/coveralls/jgraichen/msgr/master.svg)](https://coveralls.io/r/jgraichen/msgr)
|
7
|
-
[![Code Climate](http://img.shields.io/codeclimate/github/jgraichen/msgr.svg)](https://codeclimate.com/github/jgraichen/msgr)
|
3
|
+
[![Gem](https://img.shields.io/gem/v/msgr?logo=rubygems)](https://rubygems.org/gems/msgr)
|
4
|
+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/jgraichen/msgr/test?logo=github)](https://github.com/jgraichen/msgr/actions/workflows/test.yml)
|
8
5
|
[![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/msgr/master/frames)
|
9
6
|
|
10
7
|
You know it and you like it. Using Rails you can just declare your routes and
|
11
8
|
create a controller. That's all you need to process requests.
|
12
9
|
|
13
|
-
With
|
10
|
+
With _Msgr_ you can do the same for asynchronous AMQP messaging. Just define
|
14
11
|
your routes, create your consumer and watch your app processing messages.
|
15
12
|
|
16
13
|
## Installation
|
@@ -82,16 +79,18 @@ class TestController < ApplicationController
|
|
82
79
|
end
|
83
80
|
```
|
84
81
|
|
82
|
+
Run client daemon with `bundle exec msgr`.
|
83
|
+
|
85
84
|
## Advanced configuration
|
86
85
|
|
87
|
-
### Manual message
|
86
|
+
### Manual message acknowledgments
|
88
87
|
|
89
|
-
Per default messages are automatically acknowledged, if no (n)ack is sent explicitly by the consumer. This can be disabled by setting the `auto_ack` attribute to `false`.
|
88
|
+
Per default messages are automatically acknowledged, if no (n)ack is sent explicitly by the consumer. This can be disabled by setting the `auto_ack` attribute to `false`.
|
90
89
|
|
91
90
|
```ruby
|
92
91
|
class TestConsumer < Msgr::Consumer
|
93
92
|
self.auto_ack = false
|
94
|
-
|
93
|
+
|
95
94
|
def index
|
96
95
|
data = { fuubar: 'abc' }
|
97
96
|
|
@@ -100,29 +99,14 @@ class TestConsumer < Msgr::Consumer
|
|
100
99
|
end
|
101
100
|
```
|
102
101
|
|
103
|
-
|
104
102
|
### Prefetch count
|
105
103
|
|
106
104
|
Per default each message queue has a prefetch count of 1. This value can be changed when specifying the messaging routes:
|
107
105
|
|
108
|
-
|
109
|
-
|
110
|
-
```
|
111
|
-
|
112
|
-
### Msgr and fork web server like unicorn
|
113
|
-
|
114
|
-
Per default msgr opens the rabbitmq connect when rails is loaded. If you use a multi-process web server that preloads the application (like unicorn) will lead to unexpected behavior. In this case adjust `config/rabbitmq.yml` and adjust `autostart = false`:
|
115
|
-
|
116
|
-
|
117
|
-
```yaml
|
118
|
-
common: &common
|
119
|
-
uri: amqp://localhost/
|
120
|
-
autostart: false
|
106
|
+
```ruby
|
107
|
+
route 'local.test.index', to: 'test#index', prefetch: 42
|
121
108
|
```
|
122
109
|
|
123
|
-
And call inside each worker `Msgr.start` - e.g. in an after-fork block
|
124
|
-
|
125
|
-
|
126
110
|
## Testing
|
127
111
|
|
128
112
|
### Recommended configuration
|
@@ -166,7 +150,6 @@ it 'executes the consumer' do
|
|
166
150
|
end
|
167
151
|
```
|
168
152
|
|
169
|
-
|
170
153
|
## Contributing
|
171
154
|
|
172
155
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -7,26 +7,30 @@ rescue LoadError
|
|
7
7
|
end
|
8
8
|
|
9
9
|
require 'rake'
|
10
|
-
require '
|
10
|
+
require 'rake/release/task'
|
11
11
|
require 'rspec/core/rake_task'
|
12
12
|
|
13
|
+
Rake::Release::Task.new do |spec|
|
14
|
+
spec.sign_tag = true
|
15
|
+
end
|
16
|
+
|
13
17
|
# Delegate spec task task to spec:all to run all specs.
|
14
18
|
task spec: 'spec:all'
|
15
19
|
|
16
20
|
desc 'Run all specs'
|
17
21
|
namespace :spec do
|
18
22
|
desc 'Run all msgr specs and all integration specs.'
|
19
|
-
task all: %i[
|
23
|
+
task all: %i[unit integration]
|
20
24
|
|
21
25
|
desc 'Run all unit specs.'
|
22
|
-
RSpec::Core::RakeTask.new(:
|
23
|
-
t.ruby_opts = '-Ispec/
|
24
|
-
t.pattern = 'spec/
|
26
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
27
|
+
t.ruby_opts = '-Ispec/unit'
|
28
|
+
t.pattern = 'spec/unit/**/*_spec.rb'
|
25
29
|
end
|
26
30
|
|
27
31
|
desc 'Run all integration specs.'
|
28
32
|
RSpec::Core::RakeTask.new(:integration) do |t|
|
29
|
-
t.ruby_opts = '-Ispec/
|
33
|
+
t.ruby_opts = '-Ispec/integration'
|
30
34
|
t.pattern = 'spec/integration/**/*_spec.rb'
|
31
35
|
end
|
32
36
|
end
|
data/bin/msgr
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "coveralls"
|
7
|
+
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
|
8
|
+
gem "rake"
|
9
|
+
gem "rake-release", "~> 1.1"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails"
|
12
|
+
gem "rails", "~> 5.2.0"
|
13
|
+
gem "sqlite3"
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "coveralls"
|
7
|
+
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
|
8
|
+
gem "rake"
|
9
|
+
gem "rake-release", "~> 1.1"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails"
|
12
|
+
gem "rails", "~> 6.0.0"
|
13
|
+
gem "sqlite3"
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "coveralls"
|
7
|
+
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
|
8
|
+
gem "rake"
|
9
|
+
gem "rake-release", "~> 1.1"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails"
|
12
|
+
gem "rails", "~> 6.1.0"
|
13
|
+
gem "sqlite3"
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "coveralls"
|
7
|
+
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
|
8
|
+
gem "rake"
|
9
|
+
gem "rake-release", "~> 1.1"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails"
|
12
|
+
gem "rails", "~> 6.1.0"
|
13
|
+
gem "sqlite3"
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "coveralls"
|
7
|
+
gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
|
8
|
+
gem "rake"
|
9
|
+
gem "rake-release", "~> 1.1"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rspec-rails"
|
12
|
+
gem "rails", git: "https://github.com/rails/rails", require: "rails"
|
13
|
+
gem "sqlite3"
|
14
|
+
|
15
|
+
gemspec path: "../"
|
data/lib/msgr/binding.rb
CHANGED
@@ -4,7 +4,14 @@ module Msgr
|
|
4
4
|
class Binding
|
5
5
|
include Logging
|
6
6
|
|
7
|
-
attr_reader
|
7
|
+
attr_reader(
|
8
|
+
:channel,
|
9
|
+
:connection,
|
10
|
+
:dispatcher,
|
11
|
+
:queue,
|
12
|
+
:route,
|
13
|
+
:subscription,
|
14
|
+
)
|
8
15
|
|
9
16
|
def initialize(connection, route, dispatcher)
|
10
17
|
@connection = connection
|
@@ -43,13 +50,11 @@ module Msgr
|
|
43
50
|
|
44
51
|
def subscribe
|
45
52
|
@subscription = queue.subscribe(manual_ack: true) do |*args|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
"
|
51
|
-
"#{err}\n#{err.backtrace.join("\n")}"
|
52
|
-
end
|
53
|
+
dispatcher.call Message.new(channel, *args, route)
|
54
|
+
rescue StandardError => e
|
55
|
+
log(:error) do
|
56
|
+
"Rescued error from subscribe: #{e.class.name}: " \
|
57
|
+
"#{e}\n#{e.backtrace.join("\n")}"
|
53
58
|
end
|
54
59
|
end
|
55
60
|
end
|