msgr 1.3.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +83 -0
  3. data/.gitignore +17 -17
  4. data/.markdownlint.yml +22 -0
  5. data/.rubocop.yml +6 -2
  6. data/.vscode/ltex.dictionary.en-US.txt +1 -0
  7. data/Appraisals +13 -8
  8. data/CHANGELOG.md +85 -8
  9. data/Gemfile +1 -1
  10. data/README.md +17 -16
  11. data/gemfiles/rails_5.2.gemfile +2 -1
  12. data/gemfiles/rails_6.0.gemfile +2 -1
  13. data/gemfiles/rails_6.1.gemfile +2 -1
  14. data/gemfiles/rails_7.0.gemfile +15 -0
  15. data/gemfiles/{rails_master.gemfile → rails_head.gemfile} +2 -1
  16. data/lib/msgr/binding.rb +2 -2
  17. data/lib/msgr/channel.rb +2 -7
  18. data/lib/msgr/cli.rb +11 -12
  19. data/lib/msgr/client.rb +2 -2
  20. data/lib/msgr/connection.rb +2 -2
  21. data/lib/msgr/railtie.rb +1 -1
  22. data/lib/msgr/route.rb +2 -2
  23. data/lib/msgr/test_pool.rb +3 -3
  24. data/lib/msgr/version.rb +3 -3
  25. data/lib/msgr.rb +1 -3
  26. data/msgr.gemspec +6 -3
  27. data/renovate.json +5 -0
  28. data/scripts/simple_test.rb +1 -1
  29. data/spec/integration/dummy/app/consumers/test_consumer.rb +6 -1
  30. data/spec/integration/dummy/config/rabbitmq.yml +2 -0
  31. data/spec/integration/msgr/dispatcher_spec.rb +5 -6
  32. data/spec/integration/spec_helper.rb +7 -1
  33. data/spec/integration/test_controller_spec.rb +10 -2
  34. data/spec/unit/msgr/client_spec.rb +2 -2
  35. data/spec/unit/msgr/dispatcher_spec.rb +4 -4
  36. data/spec/unit/msgr/route_spec.rb +15 -1
  37. data/spec/unit/msgr/test_pool_spec.rb +14 -0
  38. data/spec/unit/msgr_spec.rb +3 -4
  39. metadata +14 -65
  40. data/.github/workflows/build.yml +0 -52
  41. data/.github/workflows/lint.yml +0 -20
  42. data/.travis.yml +0 -29
  43. data/spec/integration/dummy/db/test.sqlite3 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13657fc492608f204e15feb6dd99b4201ae0de4972c6251970009fecab1f4343
4
- data.tar.gz: 99b4dbd131d80b3d1ab7b638b78af8a3ec91d43f3a18f30bc7bec073cdd1c89d
3
+ metadata.gz: d505941f2c4bf678a5d8c5185b2d65c510fcc08aa818eca251e83e8f0225b178
4
+ data.tar.gz: 3f78955ee1074190d7fa63384294ae1b09802fcb362645b2aa52b79062ab9057
5
5
  SHA512:
6
- metadata.gz: 7097dd99d5ce3ebfe81763a9a49775ba8605ceca1695d6b736baa0db6057d1c94b0e7d5d1349d9c7df0783c3a26a858a2ee659766a06846bd914bc0fdd75982b
7
- data.tar.gz: 0ddde917911e057af0c55d0adc69e26aa4d76c8086df2aea35b7d519715555a4c06544e9befd835f3d638f40dcd6fa480f3dfbdd5e74d0c04b5c230c9d68c074
6
+ metadata.gz: e421518963ac9b653faaab3da418687a96b4a7b91dfd931e7afc8d3166b247c711a2e6eb199bcef6fc0e83d970308b2998a152b80e32b3bc1d7f248af5fd161d
7
+ data.tar.gz: 776b325f75779d39ad2c254020082da70ef4bf5a0dc1ec601c392546472315b29cfc0821718f94491d023077d1d84c7617b15ed808b9fa3f9b2aef1de56dd151
@@ -0,0 +1,83 @@
1
+ name: test
2
+ on: [push]
3
+ jobs:
4
+ test:
5
+ name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
6
+ runs-on: ubuntu-22.04
7
+
8
+ strategy:
9
+ matrix:
10
+ ruby:
11
+ - "3.2"
12
+ - "3.1"
13
+ - "3.0"
14
+ - "2.7"
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.2"
22
+ gemfile: rails_5.2.gemfile
23
+ - ruby: "3.2"
24
+ gemfile: rails_6.0.gemfile
25
+ - ruby: "3.1"
26
+ gemfile: rails_5.2.gemfile
27
+ - ruby: "3.1"
28
+ gemfile: rails_6.0.gemfile
29
+ - ruby: "3.0"
30
+ gemfile: rails_5.2.gemfile
31
+ fail-fast: False
32
+
33
+ services:
34
+ rabbitmq:
35
+ image: rabbitmq:latest
36
+ options: >-
37
+ --health-cmd "rabbitmqctl node_health_check"
38
+ --health-interval 10s
39
+ --health-timeout 5s
40
+ --health-retries 5
41
+ ports:
42
+ - 5672:5672
43
+
44
+ env:
45
+ AMQP_SERVER: amqp://localhost:5672
46
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
47
+ BUNDLE_JOBS: 4
48
+ BUNDLE_RETRY: 10
49
+ BUNDLE_WITHOUT: development
50
+
51
+ steps:
52
+ - uses: actions/checkout@master
53
+
54
+ - name: Setup Ruby
55
+ uses: ruby/setup-ruby@v1
56
+ with:
57
+ ruby-version: ${{ matrix.ruby }}
58
+ bundler-cache: True
59
+
60
+ - name: Run unit tests
61
+ run: bundle exec rspec -Ispec/unit --color spec/unit
62
+
63
+ - name: Run integration tests
64
+ run: bundle exec rspec -Ispec/integration --color spec/integration
65
+
66
+ rubocop:
67
+ name: rubocop
68
+ runs-on: ubuntu-22.04
69
+
70
+ env:
71
+ BUNDLE_JOBS: 4
72
+ BUNDLE_RETRY: 10
73
+ BUNDLE_WITHOUT: development
74
+
75
+ steps:
76
+ - uses: actions/checkout@master
77
+ - uses: ruby/setup-ruby@v1
78
+ with:
79
+ ruby-version: 3.0
80
+ bundler-cache: true
81
+
82
+ - name: Run rubocop
83
+ run: bundle exec rubocop --parallel --color
data/.gitignore CHANGED
@@ -1,29 +1,29 @@
1
- *.gem
2
- *.rbc
1
+ _yardoc
3
2
  .bundle
4
3
  .config
4
+ .idea
5
+ .rbx
6
+ .rspec
5
7
  .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
8
+ *.gem
9
+ *.iml
10
+ *.lock
11
+ *.log
12
+ *.rbc
9
13
  coverage
10
14
  doc/
15
+ InstalledFiles
11
16
  lib/bundler/man
12
17
  pkg
18
+ pmip
13
19
  rdoc
20
+ spec/integration/dummy/.generators
21
+ spec/integration/dummy/.rakeTasks
22
+ spec/integration/dummy/.sass-cache
23
+ spec/integration/dummy/db/*.sqlite3
24
+ spec/integration/dummy/db/*.sqlite3-journal
25
+ spec/integration/dummy/tmp
14
26
  spec/reports
15
27
  test/tmp
16
28
  test/version_tmp
17
29
  tmp
18
- .idea
19
- pmip
20
- *.iml
21
- .rbx
22
- .rspec
23
- *.log
24
- spec/integration/dummy/db/*.sqlite3
25
- spec/integration/dummy/db/*.sqlite3-journal
26
- spec/integration/dummy/tmp
27
- spec/integration/dummy/.sass-cache
28
- spec/integration/dummy/.generators
29
- spec/integration/dummy/.rakeTasks
data/.markdownlint.yml ADDED
@@ -0,0 +1,22 @@
1
+ # markdownlint config
2
+
3
+ # The CHANGELOG contains duplicated headers by design
4
+ MD024: false
5
+
6
+ # MD013/line-length: disable line length for all. We prefer lines as
7
+ # long as paragraph with in-editor line breaks.
8
+ MD013: false
9
+
10
+ # MD033/no-inline-html: allow often need tags
11
+ MD033:
12
+ allowed_elements:
13
+ - figure
14
+ - figcaption
15
+
16
+ # MD046/code-block-style: code block style conflicting with
17
+ # admonitions...
18
+ MD046: false
19
+
20
+ # MD048/code-fence-style: code fence style
21
+ MD048:
22
+ style: backtick
data/.rubocop.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  inherit_gem:
2
- my-rubocop: default.yml
2
+ rubocop-config: default.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
5
+ TargetRubyVersion: 2.7
6
+ SuggestExtensions: False
6
7
  Exclude:
7
8
  - gemfiles/**/*
8
9
  - spec/integration/dummy/**/*
@@ -11,3 +12,6 @@ AllCops:
11
12
  Layout/LineLength:
12
13
  Exclude:
13
14
  - spec/**/*
15
+
16
+ RSpec/MultipleMemoizedHelpers:
17
+ Max: 15
@@ -0,0 +1 @@
1
+ AMQP
data/Appraisals CHANGED
@@ -1,18 +1,23 @@
1
1
  # frozen_string_literal: true
2
- # -*- mode: ruby -*-
3
2
 
4
- appraise 'rails-5.2' do
5
- gem 'rails', '~> 5.2.0'
6
- end
3
+ # vim: ft=ruby
7
4
 
8
- appraise 'rails-6.0' do
9
- gem 'rails', '~> 6.0.0'
10
- end
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
11
12
 
12
13
  appraise 'rails-6.1' do
13
14
  gem 'rails', '~> 6.1.0'
14
15
  end
15
16
 
16
- appraise 'rails-master' do
17
+ appraise 'rails-7.0' do
18
+ gem 'rails', '~> 6.1.0'
19
+ end
20
+
21
+ appraise 'rails-head' do
17
22
  gem 'rails', git: 'https://github.com/rails/rails', require: 'rails'
18
23
  end
data/CHANGELOG.md CHANGED
@@ -1,54 +1,99 @@
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.5.0] - 2023-08-16
10
+
11
+ ### Added
12
+
13
+ - Support for Ruby 3.1 and 3.2
14
+
15
+ ### Changed
16
+
17
+ - Drop support for Ruby < 2.7
18
+
19
+ ### Fixed
20
+
21
+ - `TestPool#run` passing down keyword arguments
22
+
23
+ ## [1.4.0] - 2022-01-10
24
+
25
+ ### Added
26
+
27
+ - Support for namespaced consumer classes in routes file (#48, #49)
28
+
29
+ ### Removed
30
+
31
+ - Unused `Channel#reject` method
32
+
8
33
  ## [1.3.2] - 2021-09-21
34
+
9
35
  ### Fixed
36
+
10
37
  - Rake task `msgr:drain` ran before all routes were initialized (#44)
11
38
 
12
39
  ## [1.3.1] - 2020-12-16
40
+
13
41
  ### Fixed
42
+
14
43
  - Delay setting default options for correct relative routing file path
15
44
 
16
45
  ## [1.3.0] - 2020-12-16
46
+
17
47
  ### Added
48
+
18
49
  - Support and testing for Rails 6.1
19
50
  - Rake task for purging all known queues (#43)
20
51
 
21
52
  ### Changed
53
+
22
54
  - High-risk feature to autostart client in-process has been removed without replacement
23
55
  - Parsing config is more relaxed now but directly based on YAML boolean values
24
56
 
25
57
  ## [1.2.0] - 2019-06-27
58
+
26
59
  ### Added
60
+
27
61
  - Test support of Rails 5.2
28
62
 
29
63
  ### Changed
30
- - Serialize JSON using core JSON instead of MultiJson
64
+
65
+ - Serialize JSON using core JSON instead of `MultiJson`
31
66
  - Remove application/text fallback for payload (#25)
32
67
 
33
68
  ## [1.1.0] - 2018-07-25
69
+
34
70
  ### Added
71
+
35
72
  - New command line runner
36
73
 
37
74
  ## [1.0.0] - 2017-12-29
75
+
38
76
  ### Changed
77
+
39
78
  - Configure prefetch per binding and disable auto ack in consumer for customized batch processing (#15)
40
79
  - Replace usage of deprecated exception class (#12)
41
80
 
42
81
  ## [0.15.2] - 2017-09-04
82
+
43
83
  ### Fixed
84
+
44
85
  - Fix regression in parsing `:uri` config with empty path
45
86
 
46
87
  ## [0.15.1] - 2017-07-31
88
+
47
89
  ### Fixed
90
+
48
91
  - Fix errors with additional configuration keys for AMQP connection (#13)
49
92
 
50
93
  ## [0.15.0] - 2017-03-30
94
+
51
95
  ### Added
96
+
52
97
  - Add new configuration option `:raise_exceptions` that can be used to enable
53
98
  exceptions being raised from consumers. Mostly useful for testing consumers.
54
99
  Defaults to `false`.
@@ -56,69 +101,101 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
56
101
  - Add methods for purging queues
57
102
 
58
103
  ### Changed
59
- - Rework TestPool timeout handling to not account processing time
104
+
105
+ - Rework `TestPool` timeout handling to not account processing time
60
106
 
61
107
  ## [0.14.1] - 2016-02-17
108
+
62
109
  ### Fixed
110
+
63
111
  - Fix loading test pool source file
64
112
 
65
113
  ## [0.14.0] - 2016-02-17
114
+
66
115
  ### Added
116
+
67
117
  - Add experimental test pool (`Msgr::TestPool`)
68
118
 
69
119
  ## [0.13.0] - 2015-08-24
120
+
70
121
  ### Changed
122
+
71
123
  - Use `Rails.application.config_for` if available.
72
124
 
73
125
  ## [0.12.2] - 2015-01-14
126
+
74
127
  ### Changed
128
+
75
129
  - Do not delete the exchange on stop delete:true - as the exchange is changed
76
130
 
77
131
  ## [0.12.1] - 2014-11-06
132
+
78
133
  ### Changed
134
+
79
135
  - Loose dependency on bunny to allow `~> 1.4` for stone-age old RabbitMQ servers.
80
136
 
81
137
  ## [0.11.0-rc3] - 2014-04-11
138
+
82
139
  ### Added
83
- - Add checkcredentials config option to disable initial connect to rabbitmq
140
+
141
+ - Add `checkcredentials` config option to disable initial connect to RabbitMQ
84
142
  server to check the credentials
85
143
 
86
144
  ### Changed
145
+
87
146
  - Define pool_class by string to make it useable with rails
88
147
 
89
148
  ## [0.11.0-rc2] - 2014-03-29
149
+
90
150
  ### Added
91
- - Add nack for messages when an error is rescued by dispatcher
151
+
152
+ - Add `#nack` for messages when an error is rescued by dispatcher
92
153
 
93
154
  ## [0.11.0-rc1] - 2014-03-29
155
+
94
156
  ### Added
95
- - Add pool_class config to override pool classes used by dispatcher
157
+
158
+ - Add `pool_class` config to override pool classes used by dispatcher
96
159
 
97
160
  ## [0.4.1] - 2014-03-18
161
+
98
162
  ### Fixed
163
+
99
164
  - Fix bug with empty routes on client start
100
165
 
101
166
  ## [0.4.0] - 2014-03-04
167
+
102
168
  ### Changed
103
- - Improve railtie and autostart code
169
+
170
+ - Improve `Railtie` and autostart code
104
171
 
105
172
  ## 0.4.0 - 0.10.0
173
+
106
174
  ### Changed
175
+
107
176
  - Some lost history due to several crises
108
177
 
109
178
  ## [0.3.0] - 2014-03-03
179
+
110
180
  ### Added
181
+
111
182
  - Support for forking web servers like unicorn
112
183
 
113
184
  ## [0.2.1] - 2014-02-26
185
+
114
186
  ### Fixed
115
- - Fix wrong rails initializer code - was not use the config file
187
+
188
+ - Fix wrong Rails initializer code - was not use the config file
116
189
 
117
190
  ## [0.2.0] - 2014-02-21
191
+
118
192
  ### Changed
193
+
119
194
  - Improve rails initializer code
120
195
 
121
- [Unreleased]: https://github.com/jgraichen/msgr/compare/v1.3.2...HEAD
196
+ [Unreleased]: https://github.com/jgraichen/msgr/compare/v1.5.0...HEAD
197
+ [1.5.0]: https://github.com/jgraichen/msgr/compare/v1.4.0...v1.5.0
198
+ [1.4.0]: https://github.com/jgraichen/msgr/compare/v1.3.2...v1.4.0
122
199
  [1.3.2]: https://github.com/jgraichen/msgr/compare/v1.3.1...v1.3.2
123
200
  [1.3.1]: https://github.com/jgraichen/msgr/compare/v1.3.0...v1.3.1
124
201
  [1.3.0]: https://github.com/jgraichen/msgr/compare/v1.2.0...v1.3.0
data/Gemfile CHANGED
@@ -4,11 +4,11 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'appraisal'
6
6
  gem 'coveralls'
7
- gem 'my-rubocop', github: 'jgraichen/my-rubocop'
8
7
  gem 'rake'
9
8
  gem 'rake-release', '~> 1.1'
10
9
  gem 'rspec', '~> 3.0'
11
10
  gem 'rspec-rails'
11
+ gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: 'v11', require: false
12
12
 
13
13
  gem 'rails'
14
14
  gem 'sqlite3'
data/README.md CHANGED
@@ -1,34 +1,38 @@
1
- # Msgr: *Rails-like Messaging Framework*
1
+ # Msgr: _Rails-like Messaging Framework_
2
2
 
3
-
4
- [![Gem Version](https://badge.fury.io/rb/msgr.svg)](http://badge.fury.io/rb/msgr)
5
- [![Build Status](https://travis-ci.org/jgraichen/msgr.svg?branch=master)](https://travis-ci.org/jgraichen/msgr)
6
- [![Build Status](https://github.com/jgraichen/msgr/workflows/Build/badge.svg?branch=master)](https://github.com/jgraichen/msgr/actions?query=workflow%3ABuild+branch%3Amaster)
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/actions/workflow/status/jgraichen/msgr/test.yml?branch=main&logo=github)](https://github.com/jgraichen/msgr/actions/workflows/test.yml)
7
5
  [![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/msgr/master/frames)
8
6
 
9
7
  You know it and you like it. Using Rails you can just declare your routes and
10
8
  create a controller. That's all you need to process requests.
11
9
 
12
- With *Msgr* you can do the same for asynchronous AMQP messaging. Just define
10
+ With _Msgr_ you can do the same for asynchronous AMQP messaging. Just define
13
11
  your routes, create your consumer and watch your app processing messages.
14
12
 
15
13
  ## Installation
16
14
 
17
15
  Add this line to your application's Gemfile:
18
16
 
19
- gem 'msgr'
17
+ ```ruby
18
+ gem 'msgr', '~> 1.5'
19
+ ```
20
20
 
21
21
  And then execute:
22
22
 
23
- $ bundle
23
+ ```console
24
+ bundle
25
+ ```
24
26
 
25
27
  Or install it yourself as:
26
28
 
27
- $ gem install msgr
29
+ ```console
30
+ gem install msgr
31
+ ```
28
32
 
29
33
  ## Usage
30
34
 
31
- After adding 'msgr' to your gemfile create a `config/rabbitmq.yml` like this:
35
+ After adding 'msgr' to your Gemfile create a `config/rabbitmq.yml` like this:
32
36
 
33
37
  ```yaml
34
38
  common: &common
@@ -83,7 +87,6 @@ end
83
87
 
84
88
  Run client daemon with `bundle exec msgr`.
85
89
 
86
-
87
90
  ## Advanced configuration
88
91
 
89
92
  ### Manual message acknowledgments
@@ -106,10 +109,9 @@ end
106
109
 
107
110
  Per default each message queue has a prefetch count of 1. This value can be changed when specifying the messaging routes:
108
111
 
109
- ```ruby
110
- route 'local.test.index', to: 'test#index', prefetch: 42
111
- ```
112
-
112
+ ```ruby
113
+ route 'local.test.index', to: 'test#index', prefetch: 42
114
+ ```
113
115
 
114
116
  ## Testing
115
117
 
@@ -154,7 +156,6 @@ it 'executes the consumer' do
154
156
  end
155
157
  ```
156
158
 
157
-
158
159
  ## Contributing
159
160
 
160
161
  1. Fork it
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop"
7
+ gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
8
8
  gem "rake"
9
+ gem "rake-release", "~> 1.1"
9
10
  gem "rspec", "~> 3.0"
10
11
  gem "rspec-rails"
11
12
  gem "rails", "~> 5.2.0"
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop"
7
+ gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
8
8
  gem "rake"
9
+ gem "rake-release", "~> 1.1"
9
10
  gem "rspec", "~> 3.0"
10
11
  gem "rspec-rails"
11
12
  gem "rails", "~> 6.0.0"
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop"
7
+ gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
8
8
  gem "rake"
9
+ gem "rake-release", "~> 1.1"
9
10
  gem "rspec", "~> 3.0"
10
11
  gem "rspec-rails"
11
12
  gem "rails", "~> 6.1.0"
@@ -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: "v4"
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: "../"
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop"
7
+ gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v4"
8
8
  gem "rake"
9
+ gem "rake-release", "~> 1.1"
9
10
  gem "rspec", "~> 3.0"
10
11
  gem "rspec-rails"
11
12
  gem "rails", git: "https://github.com/rails/rails", require: "rails"
data/lib/msgr/binding.rb CHANGED
@@ -10,7 +10,7 @@ module Msgr
10
10
  :dispatcher,
11
11
  :queue,
12
12
  :route,
13
- :subscription
13
+ :subscription,
14
14
  )
15
15
 
16
16
  def initialize(connection, route, dispatcher)
@@ -54,7 +54,7 @@ module Msgr
54
54
  rescue StandardError => e
55
55
  log(:error) do
56
56
  "Rescued error from subscribe: #{e.class.name}: " \
57
- "#{e}\n#{e.backtrace.join("\n")}"
57
+ "#{e}\n#{e.backtrace.join("\n")}"
58
58
  end
59
59
  end
60
60
  end
data/lib/msgr/channel.rb CHANGED
@@ -22,7 +22,7 @@ module Msgr
22
22
  @channel.topic(prefix(EXCHANGE_NAME), durable: true).tap do |ex|
23
23
  log(:debug) do
24
24
  "Created exchange #{ex.name} (type: #{ex.type}, " \
25
- "durable: #{ex.durable?}, auto_delete: #{ex.auto_delete?})"
25
+ "durable: #{ex.durable?}, auto_delete: #{ex.auto_delete?})"
26
26
  end
27
27
  end
28
28
  end
@@ -32,7 +32,7 @@ module Msgr
32
32
  @channel.queue(prefix(name), durable: true, **opts).tap do |queue|
33
33
  log(:debug) do
34
34
  "Create queue #{queue.name} (durable: #{queue.durable?}, " \
35
- "auto_delete: #{queue.auto_delete?})"
35
+ "auto_delete: #{queue.auto_delete?})"
36
36
  end
37
37
  end
38
38
  end
@@ -55,11 +55,6 @@ module Msgr
55
55
  log(:debug) { "Nacked message: #{delivery_tag}" }
56
56
  end
57
57
 
58
- def reject(delivery_tag, requeue = true)
59
- @channel.reject delivery_tag, requeue
60
- log(:debug) { "Rejected message: #{delivery_tag}" }
61
- end
62
-
63
58
  def close
64
59
  @channel.close if @channel.open?
65
60
  end
data/lib/msgr/cli.rb CHANGED
@@ -41,17 +41,16 @@ module Msgr
41
41
  Signal.trap('INT') { w.puts 'INT' }
42
42
  Signal.trap('TERM') { w.puts 'TERM' }
43
43
 
44
- Msgr.logger = Logger.new(STDOUT)
44
+ Msgr.logger = Logger.new($stdout)
45
45
  Msgr.client.start
46
46
 
47
- while (readable = IO.select([r]))
48
- case readable.first[0].gets.strip
49
- when 'INT', 'TERM'
50
- Msgr.client.stop
51
- break
52
- else
53
- exit 1
54
- end
47
+ # Wait until we receive a signal
48
+ r.wait_readable
49
+ case r.gets.strip
50
+ when 'INT', 'TERM' # Safe shutdown
51
+ Msgr.client.stop
52
+ else # Error
53
+ exit 1
55
54
  end
56
55
  end
57
56
 
@@ -65,20 +64,20 @@ module Msgr
65
64
  def parse(_argv)
66
65
  options = {
67
66
  require: Dir.pwd,
68
- environment: 'development'
67
+ environment: 'development',
69
68
  }
70
69
 
71
70
  OptionParser.new do |o|
72
71
  o.on(
73
72
  '-r', '--require [PATH|DIR]',
74
- 'Location of Rails application (default to current directory)'
73
+ 'Location of Rails application (default to current directory)',
75
74
  ) do |arg|
76
75
  options[:require] = arg
77
76
  end
78
77
 
79
78
  o.on(
80
79
  '-e', '--environment [env]',
81
- 'Rails environment (default to development)'
80
+ 'Rails environment (default to development)',
82
81
  ) do |arg|
83
82
  options[:environment] = arg
84
83
  end