msgr 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +8 -0
  3. data/.github/workflows/build.yml +52 -0
  4. data/.github/workflows/lint.yml +20 -0
  5. data/.rubocop.yml +9 -48
  6. data/.travis.yml +21 -35
  7. data/Appraisals +18 -0
  8. data/CHANGELOG.md +11 -1
  9. data/Gemfile +8 -15
  10. data/README.md +8 -20
  11. data/Rakefile +5 -5
  12. data/bin/msgr +1 -0
  13. data/gemfiles/rails_5.2.gemfile +14 -0
  14. data/gemfiles/rails_6.0.gemfile +14 -0
  15. data/gemfiles/rails_6.1.gemfile +14 -0
  16. data/gemfiles/rails_master.gemfile +14 -0
  17. data/lib/msgr.rb +1 -0
  18. data/lib/msgr/binding.rb +13 -8
  19. data/lib/msgr/channel.rb +5 -3
  20. data/lib/msgr/cli.rb +18 -11
  21. data/lib/msgr/client.rb +17 -20
  22. data/lib/msgr/connection.rb +13 -1
  23. data/lib/msgr/consumer.rb +2 -3
  24. data/lib/msgr/dispatcher.rb +7 -9
  25. data/lib/msgr/logging.rb +2 -0
  26. data/lib/msgr/message.rb +1 -2
  27. data/lib/msgr/railtie.rb +14 -69
  28. data/lib/msgr/route.rb +1 -4
  29. data/lib/msgr/routes.rb +2 -0
  30. data/lib/msgr/tasks/msgr/drain.rake +11 -0
  31. data/lib/msgr/test_pool.rb +1 -3
  32. data/lib/msgr/version.rb +1 -1
  33. data/msgr.gemspec +2 -6
  34. data/scripts/simple_test.rb +2 -3
  35. data/spec/fixtures/{msgr-routes-test-1.rb → msgr_routes_test_1.rb} +0 -0
  36. data/spec/integration/dummy/Rakefile +1 -1
  37. data/spec/{msgr/support/.keep → integration/dummy/app/assets/config/manifest.js} +0 -0
  38. data/spec/integration/dummy/bin/bundle +1 -1
  39. data/spec/integration/dummy/bin/rails +1 -1
  40. data/spec/integration/dummy/config/application.rb +1 -1
  41. data/spec/integration/dummy/config/boot.rb +2 -2
  42. data/spec/integration/dummy/config/environment.rb +1 -1
  43. data/spec/integration/dummy/config/rabbitmq.yml +1 -1
  44. data/spec/integration/msgr/dispatcher_spec.rb +28 -12
  45. data/spec/integration/msgr/railtie_spec.rb +10 -120
  46. data/spec/integration/spec_helper.rb +2 -3
  47. data/spec/integration/{msgr_spec.rb → test_controller_spec.rb} +1 -1
  48. data/spec/unit/msgr/client_spec.rb +88 -0
  49. data/spec/{msgr → unit}/msgr/connection_spec.rb +1 -1
  50. data/spec/{msgr → unit}/msgr/consumer_spec.rb +0 -0
  51. data/spec/unit/msgr/dispatcher_spec.rb +45 -0
  52. data/spec/{msgr → unit}/msgr/route_spec.rb +15 -14
  53. data/spec/{msgr → unit}/msgr/routes_spec.rb +32 -35
  54. data/spec/{msgr → unit}/msgr_spec.rb +25 -16
  55. data/spec/{msgr → unit}/spec_helper.rb +1 -1
  56. data/spec/unit/support/.keep +0 -0
  57. metadata +37 -33
  58. data/gemfiles/Gemfile.rails-4-2 +0 -7
  59. data/gemfiles/Gemfile.rails-5-0 +0 -7
  60. data/gemfiles/Gemfile.rails-5-1 +0 -7
  61. data/gemfiles/Gemfile.rails-5-2 +0 -7
  62. data/gemfiles/Gemfile.rails-master +0 -14
  63. data/spec/msgr/msgr/client_spec.rb +0 -60
  64. data/spec/msgr/msgr/dispatcher_spec.rb +0 -44
  65. data/spec/support/setup.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e99e52156e6545016340146893e7ccd3a252f2f9850f30c880497f3956723928
4
- data.tar.gz: 79279c0f92e1889c18c93f54937927a815eeb93f0b4ec50c2a0da0da7404a300
3
+ metadata.gz: 898dc0c03776cd75ab5a187e1f2e12bce0e0eaf3e9da8ff4af02102b40e74e6b
4
+ data.tar.gz: b66a13e734bf798e9d66a0bd410b5ee639fd220a5ffcf4de54f4f31cffd2d983
5
5
  SHA512:
6
- metadata.gz: 71069da32a4290f20921581a6a93c62e5490c656758ad871379cb06105bcdff4b9da85250c3d867d091a4576f30eac91e4933b5fdada452811457f8c380f4ce9
7
- data.tar.gz: 4f93760bf39df80264a9b33e0bc2d016ccc0902d866850602820a83abd28771fd92165feefc4cbc02d168045e0deb9ee5c0a6c1b762b149aebd163064b277a45
6
+ metadata.gz: 2587a3caf44a860dfaaaabf2ba0e779de75cef86979cba46129e84390322ab4f260beeada492c055c8dc6ebac3ecb3ba9f12254b4a25d04fa83f9f8f515d6450
7
+ data.tar.gz: ca8eab4d0cfe267756adf3294d78e5892c2bb940f5d936b31c7a1909df32b4348441fc2e0e088fdfd27bfb0edc7cd7b4c72d81fde6b8c511073f6176abecbaa5
@@ -0,0 +1,8 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ charset = utf-8
7
+ trim_trailing_whitespace = true
8
+ insert_final_newline = true
@@ -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
@@ -1,52 +1,13 @@
1
- AllCops:
2
- TargetRubyVersion: 2.3
3
-
1
+ inherit_gem:
2
+ my-rubocop: default.yml
4
3
 
5
- Metrics/BlockLength:
4
+ AllCops:
5
+ TargetRubyVersion: 2.5
6
6
  Exclude:
7
- - 'spec/**/*_spec.rb'
7
+ - gemfiles/**/*
8
+ - spec/integration/dummy/**/*
9
+ - vendor/**/*
8
10
 
9
- Metrics/LineLength:
11
+ Layout/LineLength:
10
12
  Exclude:
11
- - 'spec/**/*_spec.rb'
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/**/*
@@ -1,43 +1,29 @@
1
- dist: xenial
1
+ dist: bionic
2
2
  language: ruby
3
+ cache: bundler
3
4
  rvm:
4
- - 2.6.3
5
- - 2.5.5
6
- - 2.4.6
7
- - 2.3.8
5
+ - 2.7.0
6
+ - 2.6.5
7
+ - 2.5.7
8
8
  gemfile:
9
- - gemfiles/Gemfile.rails-5-2
10
- - gemfiles/Gemfile.rails-5-1
11
- - gemfiles/Gemfile.rails-5-0
12
- - gemfiles/Gemfile.rails-4-2
13
- - gemfiles/Gemfile.rails-master
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 -v'~>1.0'
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:msgr
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/Gemfile.rails-master
24
+ - gemfile: gemfiles/rails_master.gemfile
24
25
  exclude:
25
- - rvm: 2.6.3
26
- gemfile: gemfiles/Gemfile.rails-4-2
27
- - rvm: 2.4.6
28
- gemfile: gemfiles/Gemfile.rails-master
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
@@ -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
@@ -5,6 +5,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.3.0] - 2020-12-16
9
+ ### Added
10
+ - Support and testing for Rails 6.1
11
+ - Rake task for purging all known queues (#43)
12
+
13
+ ### Changed
14
+ - High-risk feature to autostart client in-process has been removed without replacement
15
+ - Parsing config is more relaxed now but directly based on YAML boolean values
16
+
8
17
  ## [1.2.0] - 2019-06-27
9
18
  ### Added
10
19
  - Test support of Rails 5.2
@@ -101,7 +110,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
101
110
  ### Changed
102
111
  - Improve rails initializer code
103
112
 
104
- [Unreleased]: https://github.com/jgraichen/msgr/compare/v1.2.0...HEAD
113
+ [Unreleased]: https://github.com/jgraichen/msgr/compare/v1.3.0...HEAD
114
+ [1.3.0]: https://github.com/jgraichen/msgr/compare/v1.2.0...v1.3.0
105
115
  [1.2.0]: https://github.com/jgraichen/msgr/compare/v1.1.0...v1.2.0
106
116
  [1.1.0]: https://github.com/jgraichen/msgr/compare/v1.0.0...v1.1.0
107
117
  [1.0.0]: https://github.com/jgraichen/msgr/compare/v0.15.2...v1.0.0
data/Gemfile CHANGED
@@ -2,22 +2,15 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- group :development, :test do
6
- gem 'coveralls'
7
- gem 'fuubar'
8
- gem 'rake'
9
- gem 'rspec', '~> 3.0'
10
- gem 'rubocop', '~> 0.72.0'
11
- end
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'
12
11
 
13
- group :rails do
14
- unless defined?(NO_RAILS_GEM)
15
- gem 'rails', '>= 4.2'
16
- gem 'sqlite3', '~> 1.3.6'
17
- end
18
-
19
- gem 'rspec-rails', require: false
20
- end
12
+ gem 'rails'
13
+ gem 'sqlite3'
21
14
 
22
15
  # Specify your gem's dependencies in acfs.gemspec
23
16
  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](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)
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 acknowledgement
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
@@ -16,17 +16,17 @@ task spec: 'spec:all'
16
16
  desc 'Run all specs'
17
17
  namespace :spec do
18
18
  desc 'Run all msgr specs and all integration specs.'
19
- task all: %i[msgr integration]
19
+ task all: %i[unit integration]
20
20
 
21
21
  desc 'Run all unit specs.'
22
- RSpec::Core::RakeTask.new(:msgr) do |t|
23
- t.ruby_opts = '-Ispec/support -rsetup -Ispec/msgr'
24
- t.pattern = 'spec/msgr/**/*_spec.rb'
22
+ RSpec::Core::RakeTask.new(:unit) do |t|
23
+ t.ruby_opts = '-Ispec/unit'
24
+ t.pattern = 'spec/unit/**/*_spec.rb'
25
25
  end
26
26
 
27
27
  desc 'Run all integration specs.'
28
28
  RSpec::Core::RakeTask.new(:integration) do |t|
29
- t.ruby_opts = '-Ispec/support -rsetup -Ispec/integration'
29
+ t.ruby_opts = '-Ispec/integration'
30
30
  t.pattern = 'spec/integration/**/*_spec.rb'
31
31
  end
32
32
  end
data/bin/msgr CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'msgr/cli'
4
5
 
@@ -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: "../"