msgr 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13657fc492608f204e15feb6dd99b4201ae0de4972c6251970009fecab1f4343
4
- data.tar.gz: 99b4dbd131d80b3d1ab7b638b78af8a3ec91d43f3a18f30bc7bec073cdd1c89d
3
+ metadata.gz: d1d1c4c93abd233370b3175719c7d41902637c1d8cae51223f86f3cd16611da9
4
+ data.tar.gz: 432388472168160b0bc1be0ee303656ab0776674d3178ac63f6c375a7395fb6c
5
5
  SHA512:
6
- metadata.gz: 7097dd99d5ce3ebfe81763a9a49775ba8605ceca1695d6b736baa0db6057d1c94b0e7d5d1349d9c7df0783c3a26a858a2ee659766a06846bd914bc0fdd75982b
7
- data.tar.gz: 0ddde917911e057af0c55d0adc69e26aa4d76c8086df2aea35b7d519715555a4c06544e9befd835f3d638f40dcd6fa480f3dfbdd5e74d0c04b5c230c9d68c074
6
+ metadata.gz: 11ce36e23b4a499aaaff01e67a1be9a91048e19e9c55cf0487491aef49d3343d1ead2cb854e4c1a1035319e524b764f62c4846e6632bac5fa81da9b7fb125329
7
+ data.tar.gz: 62e2a4460070ae90fe264f270cab8852f81d85f177e2fe77e8b730926f88a11dd651506cc1b5ef58fafefa3b23c1ea0889239beacd7ba6b8342d04d65e11e05c
@@ -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
@@ -3,6 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  TargetRubyVersion: 2.5
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
data/Appraisals CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # -*- mode: ruby -*-
2
+
3
+ # vim: ft=ruby
3
4
 
4
5
  appraise 'rails-5.2' do
5
6
  gem 'rails', '~> 5.2.0'
@@ -13,6 +14,10 @@ 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,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
+
8
19
  ## [1.3.2] - 2021-09-21
20
+
9
21
  ### Fixed
22
+
10
23
  - Rake task `msgr:drain` ran before all routes were initialized (#44)
11
24
 
12
25
  ## [1.3.1] - 2020-12-16
26
+
13
27
  ### Fixed
28
+
14
29
  - Delay setting default options for correct relative routing file path
15
30
 
16
31
  ## [1.3.0] - 2020-12-16
32
+
17
33
  ### Added
34
+
18
35
  - Support and testing for Rails 6.1
19
36
  - Rake task for purging all known queues (#43)
20
37
 
21
38
  ### Changed
39
+
22
40
  - High-risk feature to autostart client in-process has been removed without replacement
23
41
  - Parsing config is more relaxed now but directly based on YAML boolean values
24
42
 
25
43
  ## [1.2.0] - 2019-06-27
44
+
26
45
  ### Added
46
+
27
47
  - Test support of Rails 5.2
28
48
 
29
49
  ### Changed
50
+
30
51
  - Serialize JSON using core JSON instead of MultiJson
31
52
  - Remove application/text fallback for payload (#25)
32
53
 
33
54
  ## [1.1.0] - 2018-07-25
55
+
34
56
  ### Added
57
+
35
58
  - New command line runner
36
59
 
37
60
  ## [1.0.0] - 2017-12-29
61
+
38
62
  ### Changed
63
+
39
64
  - Configure prefetch per binding and disable auto ack in consumer for customized batch processing (#15)
40
65
  - Replace usage of deprecated exception class (#12)
41
66
 
42
67
  ## [0.15.2] - 2017-09-04
68
+
43
69
  ### Fixed
70
+
44
71
  - Fix regression in parsing `:uri` config with empty path
45
72
 
46
73
  ## [0.15.1] - 2017-07-31
74
+
47
75
  ### Fixed
76
+
48
77
  - Fix errors with additional configuration keys for AMQP connection (#13)
49
78
 
50
79
  ## [0.15.0] - 2017-03-30
80
+
51
81
  ### Added
82
+
52
83
  - Add new configuration option `:raise_exceptions` that can be used to enable
53
84
  exceptions being raised from consumers. Mostly useful for testing consumers.
54
85
  Defaults to `false`.
@@ -56,69 +87,100 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
56
87
  - Add methods for purging queues
57
88
 
58
89
  ### Changed
90
+
59
91
  - Rework TestPool timeout handling to not account processing time
60
92
 
61
93
  ## [0.14.1] - 2016-02-17
94
+
62
95
  ### Fixed
96
+
63
97
  - Fix loading test pool source file
64
98
 
65
99
  ## [0.14.0] - 2016-02-17
100
+
66
101
  ### Added
102
+
67
103
  - Add experimental test pool (`Msgr::TestPool`)
68
104
 
69
105
  ## [0.13.0] - 2015-08-24
106
+
70
107
  ### Changed
108
+
71
109
  - Use `Rails.application.config_for` if available.
72
110
 
73
111
  ## [0.12.2] - 2015-01-14
112
+
74
113
  ### Changed
114
+
75
115
  - Do not delete the exchange on stop delete:true - as the exchange is changed
76
116
 
77
117
  ## [0.12.1] - 2014-11-06
118
+
78
119
  ### Changed
120
+
79
121
  - Loose dependency on bunny to allow `~> 1.4` for stone-age old RabbitMQ servers.
80
122
 
81
123
  ## [0.11.0-rc3] - 2014-04-11
124
+
82
125
  ### Added
126
+
83
127
  - Add checkcredentials config option to disable initial connect to rabbitmq
84
128
  server to check the credentials
85
129
 
86
130
  ### Changed
131
+
87
132
  - Define pool_class by string to make it useable with rails
88
133
 
89
134
  ## [0.11.0-rc2] - 2014-03-29
135
+
90
136
  ### Added
137
+
91
138
  - Add nack for messages when an error is rescued by dispatcher
92
139
 
93
140
  ## [0.11.0-rc1] - 2014-03-29
141
+
94
142
  ### Added
143
+
95
144
  - Add pool_class config to override pool classes used by dispatcher
96
145
 
97
146
  ## [0.4.1] - 2014-03-18
147
+
98
148
  ### Fixed
149
+
99
150
  - Fix bug with empty routes on client start
100
151
 
101
152
  ## [0.4.0] - 2014-03-04
153
+
102
154
  ### Changed
155
+
103
156
  - Improve railtie and autostart code
104
157
 
105
158
  ## 0.4.0 - 0.10.0
159
+
106
160
  ### Changed
161
+
107
162
  - Some lost history due to several crises
108
163
 
109
164
  ## [0.3.0] - 2014-03-03
165
+
110
166
  ### Added
167
+
111
168
  - Support for forking web servers like unicorn
112
169
 
113
170
  ## [0.2.1] - 2014-02-26
171
+
114
172
  ### Fixed
173
+
115
174
  - Fix wrong rails initializer code - was not use the config file
116
175
 
117
176
  ## [0.2.0] - 2014-02-21
177
+
118
178
  ### Changed
179
+
119
180
  - Improve rails initializer code
120
181
 
121
- [Unreleased]: https://github.com/jgraichen/msgr/compare/v1.3.2...HEAD
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
122
184
  [1.3.2]: https://github.com/jgraichen/msgr/compare/v1.3.1...v1.3.2
123
185
  [1.3.1]: https://github.com/jgraichen/msgr/compare/v1.3.0...v1.3.1
124
186
  [1.3.0]: https://github.com/jgraichen/msgr/compare/v1.2.0...v1.3.0
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ 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
9
  gem 'rake-release', '~> 1.1'
10
10
  gem 'rspec', '~> 3.0'
data/README.md CHANGED
@@ -1,15 +1,13 @@
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/workflow/status/jgraichen/msgr/test?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
@@ -83,7 +81,6 @@ end
83
81
 
84
82
  Run client daemon with `bundle exec msgr`.
85
83
 
86
-
87
84
  ## Advanced configuration
88
85
 
89
86
  ### Manual message acknowledgments
@@ -106,10 +103,9 @@ end
106
103
 
107
104
  Per default each message queue has a prefetch count of 1. This value can be changed when specifying the messaging routes:
108
105
 
109
- ```ruby
110
- route 'local.test.index', to: 'test#index', prefetch: 42
111
- ```
112
-
106
+ ```ruby
107
+ route 'local.test.index', to: 'test#index', prefetch: 42
108
+ ```
113
109
 
114
110
  ## Testing
115
111
 
@@ -154,7 +150,6 @@ it 'executes the consumer' do
154
150
  end
155
151
  ```
156
152
 
157
-
158
153
  ## Contributing
159
154
 
160
155
  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: "v3"
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: "v3"
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: "v3"
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: "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: "../"
@@ -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: "v3"
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
+ readable = IO.select([r])
49
+ case readable.first[0].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
data/lib/msgr/client.rb CHANGED
@@ -14,7 +14,7 @@ module Msgr
14
14
  @config = {
15
15
  host: '127.0.0.1',
16
16
  vhost: '/',
17
- max: 2
17
+ max: 2,
18
18
  }
19
19
 
20
20
  @config.merge! parse(config.delete(:uri)) if config[:uri]
@@ -148,7 +148,7 @@ module Msgr
148
148
 
149
149
  log(:warn) do
150
150
  "Fork detected. Reset internal state. (Old PID: #{@pid} / " \
151
- "New PID: #{::Process.pid}"
151
+ "New PID: #{::Process.pid}"
152
152
  end
153
153
 
154
154
  reset
@@ -88,7 +88,7 @@ module Msgr
88
88
  if routes.empty?
89
89
  log(:warn) do
90
90
  "No routes to bound to. Bind will have no effect:\n" \
91
- " #{routes.inspect}"
91
+ " #{routes.inspect}"
92
92
  end
93
93
  else
94
94
  bind_all(routes)
data/lib/msgr/railtie.rb CHANGED
@@ -24,7 +24,7 @@ module Msgr
24
24
  # Set defaults
25
25
  config.reverse_merge!(
26
26
  checkcredentials: true,
27
- routing_file: Rails.root.join('config/msgr.rb').to_s
27
+ routing_file: Rails.root.join('config/msgr.rb').to_s,
28
28
  )
29
29
 
30
30
  Msgr.config = config
data/lib/msgr/route.rb CHANGED
@@ -4,7 +4,7 @@ module Msgr
4
4
  class Route
5
5
  attr_reader :consumer, :action, :opts
6
6
 
7
- MATCH_REGEXP = /\A(?<consumer>\w+)#(?<action>\w+)\z/.freeze
7
+ MATCH_REGEXP = %r{\A(?<consumer>(?:\w+/)*\w+)#(?<action>\w+)\z}.freeze
8
8
  def initialize(key, opts = {})
9
9
  @opts = opts
10
10
  raise ArgumentError.new 'Missing `to` options.' unless @opts[:to]
@@ -16,7 +16,7 @@ module Msgr
16
16
  unless result
17
17
  raise ArgumentError.new \
18
18
  "Invalid consumer format: #{opts[:to].strip.to_s.inspect}. " \
19
- 'Must be `consumer_class#action`.'
19
+ 'Must be `name/space/consumer_class#action`.'
20
20
  end
21
21
 
22
22
  @consumer = "#{result[:consumer].camelize}Consumer"
data/lib/msgr/version.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  module Msgr
4
4
  module VERSION
5
5
  MAJOR = 1
6
- MINOR = 3
7
- PATCH = 2
6
+ MINOR = 4
7
+ PATCH = 0
8
8
  STAGE = nil
9
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
10
10
 
data/lib/msgr.rb CHANGED
@@ -25,7 +25,7 @@ require 'msgr/railtie' if defined? Rails
25
25
 
26
26
  module Msgr
27
27
  class << self
28
- attr_writer :client, :config
28
+ attr_writer :client, :config, :logger
29
29
 
30
30
  delegate :publish, to: :client
31
31
 
@@ -46,8 +46,6 @@ module Msgr
46
46
  @logger
47
47
  end
48
48
 
49
- attr_writer :logger
50
-
51
49
  def start
52
50
  client.start
53
51
  client
data/msgr.gemspec CHANGED
@@ -15,11 +15,17 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = 'https://github.com/jgraichen/msgr'
16
16
  spec.license = 'MIT'
17
17
 
18
+ spec.metadata = {
19
+ 'rubygems_mfa_required' => 'true',
20
+ }
21
+
18
22
  spec.files = `git ls-files -z`.split("\x0")
19
23
  spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
20
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
25
  spec.require_paths = %w[lib]
22
26
 
27
+ spec.required_ruby_version = '>= 2.5'
28
+
23
29
  spec.add_dependency 'activesupport'
24
30
  spec.add_dependency 'bunny', '>= 1.4', '< 3.0'
25
31
 
data/renovate.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ]
5
+ }
@@ -28,7 +28,7 @@ class NullPool
28
28
  end
29
29
 
30
30
  @client = Msgr::Client.new user: 'guest', password: 'guest',
31
- max: 4 # , pool_class: 'NullPool'
31
+ max: 4 # , pool_class: 'NullPool'
32
32
 
33
33
  @client.routes.configure do
34
34
  route 'abc.#', to: 'test#index'
@@ -34,6 +34,12 @@ describe Msgr::Route do
34
34
  described_class.new routing_key, to: 'abc'
35
35
  end.to raise_error ArgumentError, /invalid consumer format/i
36
36
  end
37
+
38
+ it 'allows namespaces in consumer' do
39
+ expect do
40
+ described_class.new routing_key, to: 'abc/def#ghi'
41
+ end.not_to raise_error
42
+ end
37
43
  end
38
44
 
39
45
  describe '#consumer' do
@@ -44,10 +50,18 @@ describe Msgr::Route do
44
50
  context 'with underscore consumer name' do
45
51
  let(:options) { super().merge to: 'test_resource_foo#index' }
46
52
 
47
- it 'returns camelized method name' do
53
+ it 'returns camelized class name' do
48
54
  expect(route.consumer).to eq 'TestResourceFooConsumer'
49
55
  end
50
56
  end
57
+
58
+ context 'with nested namespace in consumer name' do
59
+ let(:options) { super().merge to: 'nested/namespace/foo#index' }
60
+
61
+ it 'returns fully classified, classified class name' do
62
+ expect(route.consumer).to eq 'Nested::Namespace::FooConsumer'
63
+ end
64
+ end
51
65
  end
52
66
 
53
67
  describe '#action' do
@@ -2,8 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- class Receiver
6
- end
5
+ Receiver = Class.new
7
6
 
8
7
  class MsgrTestConsumer < Msgr::Consumer
9
8
  def index
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -67,11 +67,9 @@ extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
69
  - ".editorconfig"
70
- - ".github/workflows/build.yml"
71
- - ".github/workflows/lint.yml"
70
+ - ".github/workflows/test.yml"
72
71
  - ".gitignore"
73
72
  - ".rubocop.yml"
74
- - ".travis.yml"
75
73
  - Appraisals
76
74
  - CHANGELOG.md
77
75
  - Gemfile
@@ -82,7 +80,8 @@ files:
82
80
  - gemfiles/rails_5.2.gemfile
83
81
  - gemfiles/rails_6.0.gemfile
84
82
  - gemfiles/rails_6.1.gemfile
85
- - gemfiles/rails_master.gemfile
83
+ - gemfiles/rails_7.0.gemfile
84
+ - gemfiles/rails_head.gemfile
86
85
  - lib/msgr.rb
87
86
  - lib/msgr/binding.rb
88
87
  - lib/msgr/channel.rb
@@ -101,6 +100,7 @@ files:
101
100
  - lib/msgr/test_pool.rb
102
101
  - lib/msgr/version.rb
103
102
  - msgr.gemspec
103
+ - renovate.json
104
104
  - scripts/simple_test.rb
105
105
  - spec/fixtures/msgr_routes_test_1.rb
106
106
  - spec/fixtures/msgr_routes_test_drain.rb
@@ -145,7 +145,8 @@ files:
145
145
  homepage: https://github.com/jgraichen/msgr
146
146
  licenses:
147
147
  - MIT
148
- metadata: {}
148
+ metadata:
149
+ rubygems_mfa_required: 'true'
149
150
  post_install_message:
150
151
  rdoc_options: []
151
152
  require_paths:
@@ -154,14 +155,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
154
155
  requirements:
155
156
  - - ">="
156
157
  - !ruby/object:Gem::Version
157
- version: '0'
158
+ version: '2.5'
158
159
  required_rubygems_version: !ruby/object:Gem::Requirement
159
160
  requirements:
160
161
  - - ">="
161
162
  - !ruby/object:Gem::Version
162
163
  version: '0'
163
164
  requirements: []
164
- rubygems_version: 3.2.4
165
+ rubygems_version: 3.1.6
165
166
  signing_key:
166
167
  specification_version: 4
167
168
  summary: 'Msgr: Rails-like Messaging Framework'
@@ -1,52 +0,0 @@
1
- name: Build
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
- - '2.7'
12
- - '2.6'
13
- - '2.5'
14
- gemfile:
15
- - rails_5.2.gemfile
16
- - rails_6.0.gemfile
17
- - rails_6.1.gemfile
18
- fail-fast: false
19
-
20
- services:
21
- rabbitmq:
22
- image: rabbitmq:latest
23
- options: --health-cmd "rabbitmqctl node_health_check" --health-interval 10s --health-timeout 5s --health-retries 5
24
- ports:
25
- - 5672:5672
26
-
27
- steps:
28
- - uses: actions/checkout@master
29
-
30
- - name: Setup Ruby
31
- uses: ruby/setup-ruby@v1
32
- with:
33
- ruby-version: ${{ matrix.ruby }}
34
- bundler-cache: true
35
- bundler: 1
36
- env:
37
- BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
38
- BUNDLE_WITHOUT: development
39
- BUNDLE_JOBS: 4
40
- BUNDLE_RETRY: 3
41
-
42
- - name: Run unit tests
43
- env:
44
- AMQP_SERVER: amqp://localhost:5672
45
- BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
46
- run: bundle exec rspec -Ispec/unit --color spec/unit
47
-
48
- - name: Run integration tests
49
- env:
50
- AMQP_SERVER: amqp://localhost:5672
51
- BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
52
- run: bundle exec rspec -Ispec/integration --color spec/integration
@@ -1,20 +0,0 @@
1
- name: Lint
2
- on: [push]
3
- jobs:
4
- rubocop:
5
- name: rubocop
6
- runs-on: ubuntu-20.04
7
-
8
- steps:
9
- - uses: actions/checkout@master
10
- - uses: ruby/setup-ruby@v1
11
- with:
12
- ruby-version: 2.6
13
- bundler-cache: true
14
- env:
15
- BUNDLE_WITHOUT: development
16
- BUNDLE_JOBS: 4
17
- BUNDLE_RETRY: 3
18
-
19
- - name: Run rubocop
20
- run: bundle exec rubocop --parallel --color
data/.travis.yml DELETED
@@ -1,29 +0,0 @@
1
- dist: bionic
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.0
6
- - 2.6.5
7
- - 2.5.7
8
- gemfile:
9
- - gemfiles/rails_42.gemfile
10
- - gemfiles/rails_50.gemfile
11
- - gemfiles/rails_51.gemfile
12
- - gemfiles/rails_52.gemfile
13
- - gemfiles/rails_60.gemfile
14
- - gemfiles/rails_master.gemfile
15
- before_install:
16
- - sudo apt-get install -qy rabbitmq-server
17
- - echo yes | rvm gemset delete global
18
- - gem install bundler --version '~> 1.0'
19
- script:
20
- - bundle exec rake spec:unit
21
- - bundle exec rake spec:integration
22
- jobs:
23
- allow_failures:
24
- - gemfile: gemfiles/rails_master.gemfile
25
- exclude:
26
- - rvm: 2.7.0
27
- gemfile: gemfiles/rails_42.gemfile
28
- - rvm: 2.6.5
29
- gemfile: gemfiles/rails_42.gemfile