msgr 1.1.0.1.b306 → 1.3.2
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/build.yml +52 -0
- data/.github/workflows/lint.yml +20 -0
- data/.rubocop.yml +9 -48
- data/.travis.yml +21 -35
- data/Appraisals +18 -0
- data/CHANGELOG.md +34 -11
- data/Gemfile +9 -15
- data/README.md +8 -20
- data/Rakefile +10 -6
- data/bin/msgr +1 -0
- data/gemfiles/rails_5.2.gemfile +14 -0
- data/gemfiles/rails_6.0.gemfile +14 -0
- data/gemfiles/rails_6.1.gemfile +14 -0
- data/gemfiles/rails_master.gemfile +14 -0
- data/lib/msgr/binding.rb +13 -8
- data/lib/msgr/channel.rb +5 -3
- data/lib/msgr/cli.rb +18 -11
- data/lib/msgr/client.rb +25 -23
- data/lib/msgr/connection.rb +13 -1
- 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 +1 -4
- 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 +2 -2
- data/lib/msgr.rb +1 -0
- data/msgr.gemspec +2 -6
- data/scripts/simple_test.rb +2 -3
- 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 +15 -14
- data/spec/{msgr → unit}/msgr/routes_spec.rb +32 -35
- data/spec/{msgr → unit}/msgr_spec.rb +25 -16
- data/spec/{msgr → unit}/spec_helper.rb +1 -1
- data/spec/unit/support/.keep +0 -0
- metadata +41 -36
- 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: 13657fc492608f204e15feb6dd99b4201ae0de4972c6251970009fecab1f4343
|
4
|
+
data.tar.gz: 99b4dbd131d80b3d1ab7b638b78af8a3ec91d43f3a18f30bc7bec073cdd1c89d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7097dd99d5ce3ebfe81763a9a49775ba8605ceca1695d6b736baa0db6057d1c94b0e7d5d1349d9c7df0783c3a26a858a2ee659766a06846bd914bc0fdd75982b
|
7
|
+
data.tar.gz: 0ddde917911e057af0c55d0adc69e26aa4d76c8086df2aea35b7d519715555a4c06544e9befd835f3d638f40dcd6fa480f3dfbdd5e74d0c04b5c230c9d68c074
|
data/.editorconfig
ADDED
@@ -0,0 +1,52 @@
|
|
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
|
@@ -0,0 +1,20 @@
|
|
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/.rubocop.yml
CHANGED
@@ -1,52 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
inherit_gem:
|
2
|
+
my-rubocop: default.yml
|
4
3
|
|
5
|
-
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.5
|
6
6
|
Exclude:
|
7
|
-
-
|
7
|
+
- gemfiles/**/*
|
8
|
+
- spec/integration/dummy/**/*
|
9
|
+
- vendor/**/*
|
8
10
|
|
9
|
-
|
11
|
+
Layout/LineLength:
|
10
12
|
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
|
50
|
-
|
51
|
-
Style/TrivialAccessors:
|
52
|
-
AllowPredicates: true
|
13
|
+
- spec/**/*
|
data/.travis.yml
CHANGED
@@ -1,43 +1,29 @@
|
|
1
|
-
dist:
|
1
|
+
dist: bionic
|
2
2
|
language: ruby
|
3
|
+
cache: bundler
|
3
4
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.3.8
|
5
|
+
- 2.7.0
|
6
|
+
- 2.6.5
|
7
|
+
- 2.5.7
|
8
8
|
gemfile:
|
9
|
-
- gemfiles/
|
10
|
-
- gemfiles/
|
11
|
-
- gemfiles/
|
12
|
-
- gemfiles/
|
13
|
-
- gemfiles/
|
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
|
14
15
|
before_install:
|
15
|
-
- sudo apt-get install -qy rabbitmq-server
|
16
|
-
- echo yes | rvm gemset delete global
|
17
|
-
- gem install bundler
|
16
|
+
- sudo apt-get install -qy rabbitmq-server
|
17
|
+
- echo yes | rvm gemset delete global
|
18
|
+
- gem install bundler --version '~> 1.0'
|
18
19
|
script:
|
19
|
-
- bundle exec rake spec:
|
20
|
-
- bundle exec rake spec:integration
|
20
|
+
- bundle exec rake spec:unit
|
21
|
+
- bundle exec rake spec:integration
|
21
22
|
jobs:
|
22
23
|
allow_failures:
|
23
|
-
- gemfile: gemfiles/
|
24
|
+
- gemfile: gemfiles/rails_master.gemfile
|
24
25
|
exclude:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
- rvm: 2.3.8
|
30
|
-
gemfile: gemfiles/Gemfile.rails-master
|
31
|
-
include:
|
32
|
-
- stage: Beta release
|
33
|
-
rvm: 2.6.3
|
34
|
-
script: echo "Deploy to rubygems.org..."
|
35
|
-
deploy:
|
36
|
-
provider: rubygems
|
37
|
-
api_key:
|
38
|
-
secure: g8icPMdxEmbpBzSRCDmR3uB+1Zhu7tGq3h0cVbGUka2Ni1NiEiQo3LCDzbMp+L7AXH5RhdsG9FTViIAyCy9YENqZ1+jzrQGeADx0KnJZb6F81/SyumeUld0zdkzDbe1aUCJWz2WnEk12aLMPLNPRmDE7wub+od7gJEEv2SsKObo=
|
39
|
-
gem: msgr
|
40
|
-
on:
|
41
|
-
branch: master
|
42
|
-
repo: jgraichen/msgr
|
43
|
-
|
26
|
+
- rvm: 2.7.0
|
27
|
+
gemfile: gemfiles/rails_42.gemfile
|
28
|
+
- rvm: 2.6.5
|
29
|
+
gemfile: gemfiles/rails_42.gemfile
|
data/Appraisals
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# -*- mode: ruby -*-
|
3
|
+
|
4
|
+
appraise 'rails-5.2' do
|
5
|
+
gem 'rails', '~> 5.2.0'
|
6
|
+
end
|
7
|
+
|
8
|
+
appraise 'rails-6.0' do
|
9
|
+
gem 'rails', '~> 6.0.0'
|
10
|
+
end
|
11
|
+
|
12
|
+
appraise 'rails-6.1' do
|
13
|
+
gem 'rails', '~> 6.1.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
appraise 'rails-master' do
|
17
|
+
gem 'rails', git: 'https://github.com/rails/rails', require: 'rails'
|
18
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
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
5
|
|
6
6
|
## [Unreleased]
|
7
|
+
|
8
|
+
## [1.3.2] - 2021-09-21
|
9
|
+
### Fixed
|
10
|
+
- Rake task `msgr:drain` ran before all routes were initialized (#44)
|
11
|
+
|
12
|
+
## [1.3.1] - 2020-12-16
|
13
|
+
### Fixed
|
14
|
+
- Delay setting default options for correct relative routing file path
|
15
|
+
|
16
|
+
## [1.3.0] - 2020-12-16
|
17
|
+
### Added
|
18
|
+
- Support and testing for Rails 6.1
|
19
|
+
- Rake task for purging all known queues (#43)
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
- High-risk feature to autostart client in-process has been removed without replacement
|
23
|
+
- Parsing config is more relaxed now but directly based on YAML boolean values
|
24
|
+
|
25
|
+
## [1.2.0] - 2019-06-27
|
7
26
|
### Added
|
8
27
|
- Test support of Rails 5.2
|
9
28
|
|
@@ -59,7 +78,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
59
78
|
### Changed
|
60
79
|
- Loose dependency on bunny to allow `~> 1.4` for stone-age old RabbitMQ servers.
|
61
80
|
|
62
|
-
## [0.11.0
|
81
|
+
## [0.11.0-rc3] - 2014-04-11
|
63
82
|
### Added
|
64
83
|
- Add checkcredentials config option to disable initial connect to rabbitmq
|
65
84
|
server to check the credentials
|
@@ -67,18 +86,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
67
86
|
### Changed
|
68
87
|
- Define pool_class by string to make it useable with rails
|
69
88
|
|
70
|
-
## [0.11.0
|
89
|
+
## [0.11.0-rc2] - 2014-03-29
|
71
90
|
### Added
|
72
91
|
- Add nack for messages when an error is rescued by dispatcher
|
73
92
|
|
74
|
-
## [0.11.0
|
93
|
+
## [0.11.0-rc1] - 2014-03-29
|
75
94
|
### Added
|
76
95
|
- Add pool_class config to override pool classes used by dispatcher
|
77
96
|
|
78
|
-
## 0.4 - 0.10
|
79
|
-
### Changed
|
80
|
-
- Some lost history due to several crises
|
81
|
-
|
82
97
|
## [0.4.1] - 2014-03-18
|
83
98
|
### Fixed
|
84
99
|
- Fix bug with empty routes on client start
|
@@ -87,6 +102,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
87
102
|
### Changed
|
88
103
|
- Improve railtie and autostart code
|
89
104
|
|
105
|
+
## 0.4.0 - 0.10.0
|
106
|
+
### Changed
|
107
|
+
- Some lost history due to several crises
|
108
|
+
|
90
109
|
## [0.3.0] - 2014-03-03
|
91
110
|
### Added
|
92
111
|
- Support for forking web servers like unicorn
|
@@ -99,7 +118,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
99
118
|
### Changed
|
100
119
|
- Improve rails initializer code
|
101
120
|
|
102
|
-
[Unreleased]: https://github.com/jgraichen/msgr/compare/v1.
|
121
|
+
[Unreleased]: https://github.com/jgraichen/msgr/compare/v1.3.2...HEAD
|
122
|
+
[1.3.2]: https://github.com/jgraichen/msgr/compare/v1.3.1...v1.3.2
|
123
|
+
[1.3.1]: https://github.com/jgraichen/msgr/compare/v1.3.0...v1.3.1
|
124
|
+
[1.3.0]: https://github.com/jgraichen/msgr/compare/v1.2.0...v1.3.0
|
125
|
+
[1.2.0]: https://github.com/jgraichen/msgr/compare/v1.1.0...v1.2.0
|
103
126
|
[1.1.0]: https://github.com/jgraichen/msgr/compare/v1.0.0...v1.1.0
|
104
127
|
[1.0.0]: https://github.com/jgraichen/msgr/compare/v0.15.2...v1.0.0
|
105
128
|
[0.15.2]: https://github.com/jgraichen/msgr/compare/v0.15.1...v0.15.2
|
@@ -110,9 +133,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
110
133
|
[0.13.0]: https://github.com/jgraichen/msgr/compare/v0.12.3...v0.13.0
|
111
134
|
[0.12.2]: https://github.com/jgraichen/msgr/compare/v0.12.1...v0.12.2
|
112
135
|
[0.12.1]: https://github.com/jgraichen/msgr/compare/v0.12.0...v0.12.1
|
113
|
-
[0.11.0
|
114
|
-
[0.11.0
|
115
|
-
[0.11.0
|
136
|
+
[0.11.0-rc3]: https://github.com/jgraichen/msgr/compare/v0.11.0.rc2...v0.11.0.rc3
|
137
|
+
[0.11.0-rc2]: https://github.com/jgraichen/msgr/compare/v0.11.0.rc1...v0.11.0.rc2
|
138
|
+
[0.11.0-rc1]: https://github.com/jgraichen/msgr/compare/v0.10.2...v0.11.0.rc1
|
116
139
|
[0.4.1]: https://github.com/jgraichen/msgr/compare/v0.4.0...v0.4.1
|
117
140
|
[0.4.0]: https://github.com/jgraichen/msgr/compare/v0.3.0...v0.4.0
|
118
141
|
[0.3.0]: https://github.com/jgraichen/msgr/compare/v0.2.1...v0.3.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'
|
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
@@ -2,9 +2,8 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/msgr.svg)](http://badge.fury.io/rb/msgr)
|
5
|
-
[![Build Status](
|
6
|
-
[![
|
7
|
-
[![Code Climate](http://img.shields.io/codeclimate/github/jgraichen/msgr.svg)](https://codeclimate.com/github/jgraichen/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)
|
8
7
|
[![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/msgr/master/frames)
|
9
8
|
|
10
9
|
You know it and you like it. Using Rails you can just declare your routes and
|
@@ -82,16 +81,19 @@ class TestController < ApplicationController
|
|
82
81
|
end
|
83
82
|
```
|
84
83
|
|
84
|
+
Run client daemon with `bundle exec msgr`.
|
85
|
+
|
86
|
+
|
85
87
|
## Advanced configuration
|
86
88
|
|
87
|
-
### Manual message
|
89
|
+
### Manual message acknowledgments
|
88
90
|
|
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`.
|
91
|
+
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
92
|
|
91
93
|
```ruby
|
92
94
|
class TestConsumer < Msgr::Consumer
|
93
95
|
self.auto_ack = false
|
94
|
-
|
96
|
+
|
95
97
|
def index
|
96
98
|
data = { fuubar: 'abc' }
|
97
99
|
|
@@ -100,7 +102,6 @@ class TestConsumer < Msgr::Consumer
|
|
100
102
|
end
|
101
103
|
```
|
102
104
|
|
103
|
-
|
104
105
|
### Prefetch count
|
105
106
|
|
106
107
|
Per default each message queue has a prefetch count of 1. This value can be changed when specifying the messaging routes:
|
@@ -109,19 +110,6 @@ Per default each message queue has a prefetch count of 1. This value can be chan
|
|
109
110
|
route 'local.test.index', to: 'test#index', prefetch: 42
|
110
111
|
```
|
111
112
|
|
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
|
121
|
-
```
|
122
|
-
|
123
|
-
And call inside each worker `Msgr.start` - e.g. in an after-fork block
|
124
|
-
|
125
113
|
|
126
114
|
## Testing
|
127
115
|
|
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,14 @@
|
|
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"
|
8
|
+
gem "rake"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
gem "rspec-rails"
|
11
|
+
gem "rails", "~> 5.2.0"
|
12
|
+
gem "sqlite3"
|
13
|
+
|
14
|
+
gemspec path: "../"
|
@@ -0,0 +1,14 @@
|
|
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"
|
8
|
+
gem "rake"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
gem "rspec-rails"
|
11
|
+
gem "rails", "~> 6.0.0"
|
12
|
+
gem "sqlite3"
|
13
|
+
|
14
|
+
gemspec path: "../"
|
@@ -0,0 +1,14 @@
|
|
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"
|
8
|
+
gem "rake"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
gem "rspec-rails"
|
11
|
+
gem "rails", "~> 6.1.0"
|
12
|
+
gem "sqlite3"
|
13
|
+
|
14
|
+
gemspec path: "../"
|
@@ -0,0 +1,14 @@
|
|
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"
|
8
|
+
gem "rake"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
gem "rspec-rails"
|
11
|
+
gem "rails", git: "https://github.com/rails/rails", require: "rails"
|
12
|
+
gem "sqlite3"
|
13
|
+
|
14
|
+
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
|
data/lib/msgr/channel.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Msgr
|
2
4
|
class Channel
|
3
5
|
include Logging
|
@@ -26,8 +28,8 @@ module Msgr
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
def queue(name)
|
30
|
-
@channel.queue(prefix(name), durable: true).tap do |queue|
|
31
|
+
def queue(name, **opts)
|
32
|
+
@channel.queue(prefix(name), durable: true, **opts).tap do |queue|
|
31
33
|
log(:debug) do
|
32
34
|
"Create queue #{queue.name} (durable: #{queue.durable?}, " \
|
33
35
|
"auto_delete: #{queue.auto_delete?})"
|
@@ -62,4 +64,4 @@ module Msgr
|
|
62
64
|
@channel.close if @channel.open?
|
63
65
|
end
|
64
66
|
end
|
65
|
-
end
|
67
|
+
end
|
data/lib/msgr/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optionparser'
|
2
4
|
|
3
5
|
module Msgr
|
@@ -8,7 +10,8 @@ module Msgr
|
|
8
10
|
@options = options
|
9
11
|
|
10
12
|
if !File.exist?(options[:require]) ||
|
11
|
-
|
13
|
+
(File.directory?(options[:require]) &&
|
14
|
+
!File.exist?("#{options[:require]}/config/application.rb"))
|
12
15
|
raise <<~ERR
|
13
16
|
Rails application or required ruby file not found: #{options[:require]}
|
14
17
|
ERR
|
@@ -22,15 +25,13 @@ module Msgr
|
|
22
25
|
require 'rails'
|
23
26
|
if ::Rails::VERSION::MAJOR == 4
|
24
27
|
require File.expand_path("#{options[:require]}/config/application.rb")
|
25
|
-
::Rails::Application.initializer
|
28
|
+
::Rails::Application.initializer 'msgr.eager_load' do
|
26
29
|
::Rails.application.config.eager_load = true
|
27
30
|
end
|
28
|
-
require 'msgr/railtie'
|
29
|
-
require File.expand_path("#{options[:require]}/config/environment.rb")
|
30
|
-
else
|
31
|
-
require 'msgr/railtie'
|
32
|
-
require File.expand_path("#{options[:require]}/config/environment.rb")
|
33
31
|
end
|
32
|
+
|
33
|
+
require 'msgr/railtie'
|
34
|
+
require File.expand_path("#{options[:require]}/config/environment.rb")
|
34
35
|
else
|
35
36
|
require(options[:require])
|
36
37
|
end
|
@@ -43,7 +44,7 @@ module Msgr
|
|
43
44
|
Msgr.logger = Logger.new(STDOUT)
|
44
45
|
Msgr.client.start
|
45
46
|
|
46
|
-
while readable = IO.select([r])
|
47
|
+
while (readable = IO.select([r]))
|
47
48
|
case readable.first[0].gets.strip
|
48
49
|
when 'INT', 'TERM'
|
49
50
|
Msgr.client.stop
|
@@ -61,18 +62,24 @@ module Msgr
|
|
61
62
|
|
62
63
|
private
|
63
64
|
|
64
|
-
def parse(
|
65
|
+
def parse(_argv)
|
65
66
|
options = {
|
66
67
|
require: Dir.pwd,
|
67
68
|
environment: 'development'
|
68
69
|
}
|
69
70
|
|
70
71
|
OptionParser.new do |o|
|
71
|
-
o.on
|
72
|
+
o.on(
|
73
|
+
'-r', '--require [PATH|DIR]',
|
74
|
+
'Location of Rails application (default to current directory)'
|
75
|
+
) do |arg|
|
72
76
|
options[:require] = arg
|
73
77
|
end
|
74
78
|
|
75
|
-
o.on
|
79
|
+
o.on(
|
80
|
+
'-e', '--environment [env]',
|
81
|
+
'Rails environment (default to development)'
|
82
|
+
) do |arg|
|
76
83
|
options[:environment] = arg
|
77
84
|
end
|
78
85
|
end.parse!
|