rabbit_feed 2.3.9 → 2.3.10
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 +4 -4
- data/README.md +17 -16
- data/example/non_rails_app/Gemfile.lock +5 -5
- data/example/rails_app/Gemfile.lock +1 -1
- data/lib/rabbit_feed/configuration.rb +3 -1
- data/lib/rabbit_feed/consumer_connection.rb +1 -0
- data/lib/rabbit_feed/version.rb +1 -1
- data/spec/lib/rabbit_feed/configuration_spec.rb +3 -0
- data/spec/lib/rabbit_feed/consumer_connection_spec.rb +41 -26
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5b141fd052af473176629d66db5d86963fe4c403
         | 
| 4 | 
            +
              data.tar.gz: 38f362690f98f836cab2caef5fad99a4a8bca27a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 88e147ca7b35bf34bb703b9041eb94cbe9d4042e38df8742c55fbea6091c3e2575a64e04214ebe9010a42ae514d60fc1f2c84e6b9a46a4ad6190889722c6141a
         | 
| 7 | 
            +
              data.tar.gz: 30e4acb794167f0d505b65a3f64363f8b66f88ed6ddb77fd1d1b61aed121f44d355f5fe92576880029bc39f364dbbe26c7b378df3f478f4894f861ed0713a34e
         | 
    
        data/README.md
    CHANGED
    
    | @@ -38,22 +38,23 @@ Sample: | |
| 38 38 |  | 
| 39 39 | 
             
            Configuration options that can be specified are:
         | 
| 40 40 |  | 
| 41 | 
            -
            | Name | 
| 42 | 
            -
            | ---- | 
| 43 | 
            -
            | `host` | 
| 44 | 
            -
            | `hosts` | 
| 45 | 
            -
            | `port` | 
| 46 | 
            -
            | `user` | 
| 47 | 
            -
            | `password` | 
| 48 | 
            -
            | `application` | 
| 49 | 
            -
            | `environment` | 
| 50 | 
            -
            | `exchange` | 
| 51 | 
            -
            | `heartbeat` | 
| 52 | 
            -
            | `connect_timeout` | 
| 53 | 
            -
            | `network_recovery_interval` | Recovery interval (in seconds) periodic network recovery will use | 
| 54 | 
            -
            | `auto_delete_queue` | 
| 55 | 
            -
            | `auto_delete_exchange` | 
| 56 | 
            -
            | `route_prefix_extension` | 
| 41 | 
            +
            | Name                        | Use                                                                                                                                        |
         | 
| 42 | 
            +
            | ----                        | ---                                                                                                                                        |
         | 
| 43 | 
            +
            | `host`                      | Hostname or IP of the RabbitMQ server                                                                                                      |
         | 
| 44 | 
            +
            | `hosts`                     | Array of hostnames or IPs of a RabbitMQ cluster                                                                                            |
         | 
| 45 | 
            +
            | `port`                      | The port to use on the RabbitMQ server                                                                                                     |
         | 
| 46 | 
            +
            | `user`                      | The user to authenticate with the RabbitMQ server                                                                                          |
         | 
| 47 | 
            +
            | `password`                  | The password to authenticate with the RabbitMQ server                                                                                      |
         | 
| 48 | 
            +
            | `application`               | The name of the application - used for routing events to the specified consumers                                                           |
         | 
| 49 | 
            +
            | `environment`               | The environment of the application - used for routing events to the specified consumers                                                    |
         | 
| 50 | 
            +
            | `exchange`                  | The name of the RabbitMQ exchange to which events are published                                                                            |
         | 
| 51 | 
            +
            | `heartbeat`                 | The interval at which to send heartbeats to the RabbitMQ server (in seconds)                                                               |
         | 
| 52 | 
            +
            | `connect_timeout`           | The timeout (in seconds) for connecting to the RabbitMQ server                                                                             |
         | 
| 53 | 
            +
            | `network_recovery_interval` | Recovery interval (in seconds) periodic network recovery will use                                                                          |
         | 
| 54 | 
            +
            | `auto_delete_queue`         | If true, any queues created will auto-delete upon disconnect                                                                               |
         | 
| 55 | 
            +
            | `auto_delete_exchange`      | If true, any exchanges created will auto-delete upon disconnect                                                                            |
         | 
| 56 | 
            +
            | `route_prefix_extension`    | If set, the routing key/queue of the exchange will become env.`route_prefix_extension`.application.event                                   |
         | 
| 57 | 
            +
            | `consumer_exit_after_fail`  | If set, consumer will stop consuming as soon as it fails to process an event. By default, it will continue to consume and log the error(s) |
         | 
| 57 58 |  | 
| 58 59 | 
             
            ### Initialisation
         | 
| 59 60 |  | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: ../../
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                rabbit_feed (2.3. | 
| 4 | 
            +
                rabbit_feed (2.3.10)
         | 
| 5 5 | 
             
                  activemodel (>= 3.2.0, < 5.0.0)
         | 
| 6 6 | 
             
                  activesupport (>= 3.2.0, < 5.0.0)
         | 
| 7 7 | 
             
                  avro (>= 1.5.4, < 1.8.0)
         | 
| @@ -11,10 +11,10 @@ PATH | |
| 11 11 | 
             
            GEM
         | 
| 12 12 | 
             
              remote: https://rubygems.org/
         | 
| 13 13 | 
             
              specs:
         | 
| 14 | 
            -
                activemodel (4.2.5)
         | 
| 15 | 
            -
                  activesupport (= 4.2.5)
         | 
| 14 | 
            +
                activemodel (4.2.5.1)
         | 
| 15 | 
            +
                  activesupport (= 4.2.5.1)
         | 
| 16 16 | 
             
                  builder (~> 3.1)
         | 
| 17 | 
            -
                activesupport (4.2.5)
         | 
| 17 | 
            +
                activesupport (4.2.5.1)
         | 
| 18 18 | 
             
                  i18n (~> 0.7)
         | 
| 19 19 | 
             
                  json (~> 1.7, >= 1.7.7)
         | 
| 20 20 | 
             
                  minitest (~> 5.1)
         | 
| @@ -29,7 +29,7 @@ GEM | |
| 29 29 | 
             
                diff-lcs (1.2.5)
         | 
| 30 30 | 
             
                i18n (0.7.0)
         | 
| 31 31 | 
             
                json (1.8.3)
         | 
| 32 | 
            -
                minitest (5.8. | 
| 32 | 
            +
                minitest (5.8.4)
         | 
| 33 33 | 
             
                multi_json (1.11.2)
         | 
| 34 34 | 
             
                pidfile (0.3.0)
         | 
| 35 35 | 
             
                rake (10.4.2)
         | 
| @@ -3,7 +3,8 @@ module RabbitFeed | |
| 3 3 | 
             
                include ActiveModel::Validations
         | 
| 4 4 |  | 
| 5 5 | 
             
                attr_reader :host, :hosts, :port, :user, :password, :application, :environment, :exchange, :heartbeat,
         | 
| 6 | 
            -
                            :connect_timeout, :network_recovery_interval, :auto_delete_queue, :auto_delete_exchange
         | 
| 6 | 
            +
                            :connect_timeout, :network_recovery_interval, :auto_delete_queue, :auto_delete_exchange,
         | 
| 7 | 
            +
                            :consumer_exit_after_fail
         | 
| 7 8 | 
             
                validates_presence_of :application, :environment, :exchange
         | 
| 8 9 |  | 
| 9 10 | 
             
                def initialize options
         | 
| @@ -23,6 +24,7 @@ module RabbitFeed | |
| 23 24 | 
             
                  @application               = options[:application]
         | 
| 24 25 | 
             
                  @environment               = options[:environment]
         | 
| 25 26 | 
             
                  @route_prefix_extension    = options[:route_prefix_extension]
         | 
| 27 | 
            +
                  @consumer_exit_after_fail  = options[:consumer_exit_after_fail] || false
         | 
| 26 28 | 
             
                  validate!
         | 
| 27 29 | 
             
                end
         | 
| 28 30 |  | 
    
        data/lib/rabbit_feed/version.rb
    CHANGED
    
    
| @@ -154,6 +154,7 @@ module RabbitFeed | |
| 154 154 | 
             
                    its(:connect_timeout)           { should be_nil }
         | 
| 155 155 | 
             
                    its(:auto_delete_queue)         { should be_falsey }
         | 
| 156 156 | 
             
                    its(:auto_delete_exchange)      { should be_falsey }
         | 
| 157 | 
            +
                    its(:consumer_exit_after_fail)  { should be_falsey }
         | 
| 157 158 | 
             
                  end
         | 
| 158 159 |  | 
| 159 160 | 
             
                  context 'with provided options' do
         | 
| @@ -172,6 +173,7 @@ module RabbitFeed | |
| 172 173 | 
             
                        network_recovery_interval: 2,
         | 
| 173 174 | 
             
                        auto_delete_queue:         'true',
         | 
| 174 175 | 
             
                        auto_delete_exchange:      'false',
         | 
| 176 | 
            +
                        consumer_exit_after_fail:  'true'
         | 
| 175 177 | 
             
                      }
         | 
| 176 178 | 
             
                    end
         | 
| 177 179 |  | 
| @@ -188,6 +190,7 @@ module RabbitFeed | |
| 188 190 | 
             
                    its(:network_recovery_interval) { should eq 2 }
         | 
| 189 191 | 
             
                    its(:auto_delete_queue)         { should be_truthy }
         | 
| 190 192 | 
             
                    its(:auto_delete_exchange)      { should be_truthy }
         | 
| 193 | 
            +
                    its(:consumer_exit_after_fail)  { should be_truthy }
         | 
| 191 194 | 
             
                  end
         | 
| 192 195 |  | 
| 193 196 | 
             
                  context 'with empty options' do
         | 
| @@ -79,46 +79,61 @@ module RabbitFeed | |
| 79 79 |  | 
| 80 80 | 
             
                  context 'when an exception is raised' do
         | 
| 81 81 |  | 
| 82 | 
            -
                    context 'when  | 
| 83 | 
            -
                       | 
| 82 | 
            +
                    context 'when consumer_exit_after_fail is true' do
         | 
| 83 | 
            +
                      before { allow(RabbitFeed.configuration).to receive(:consumer_exit_after_fail).and_return(true) }
         | 
| 84 84 |  | 
| 85 | 
            -
                       | 
| 86 | 
            -
                         | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 85 | 
            +
                      it 'exits the application' do
         | 
| 86 | 
            +
                        expect_any_instance_of(described_class).to receive(:exit).with(1)
         | 
| 87 | 
            +
                        subject.consume { raise 'Consuming time' }
         | 
| 88 | 
            +
                      end
         | 
| 89 | 
            +
                    end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
             | 
| 92 | 
            +
                    context 'when consumer_exit_after_fail is false' do
         | 
| 93 | 
            +
                      before { allow(RabbitFeed.configuration).to receive(:consumer_exit_after_fail).and_return(false) }
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                      context 'when Airbrake is defined' do
         | 
| 96 | 
            +
                        after { Object.send(:remove_const, ('Airbrake').to_sym) rescue NameError }
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                        context 'when the version is lower than 5' do
         | 
| 99 | 
            +
                          before do
         | 
| 100 | 
            +
                            module ::Airbrake
         | 
| 101 | 
            +
                              VERSION = '4.0.0'
         | 
| 102 | 
            +
                            end
         | 
| 103 | 
            +
                            allow(Airbrake).to receive(:configuration).and_return(airbrake_configuration)
         | 
| 89 104 | 
             
                          end
         | 
| 90 | 
            -
                          allow(Airbrake).to receive(:configuration).and_return(airbrake_configuration)
         | 
| 91 | 
            -
                        end
         | 
| 92 105 |  | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 106 | 
            +
                          context 'and the Airbrake configuration is public' do
         | 
| 107 | 
            +
                            let(:airbrake_configuration) { double(:airbrake_configuration, public?: true) }
         | 
| 95 108 |  | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 109 | 
            +
                            it 'notifies airbrake' do
         | 
| 110 | 
            +
                              expect(Airbrake).to receive(:notify_or_ignore).with(an_instance_of RuntimeError)
         | 
| 98 111 |  | 
| 99 | 
            -
             | 
| 112 | 
            +
                              expect{ subject.consume { raise 'Consuming time' } }.not_to raise_error
         | 
| 113 | 
            +
                            end
         | 
| 100 114 | 
             
                          end
         | 
| 101 115 | 
             
                        end
         | 
| 102 | 
            -
                      end
         | 
| 103 116 |  | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 117 | 
            +
                        context 'when the version is greater than 4' do
         | 
| 118 | 
            +
                          before do
         | 
| 119 | 
            +
                            module ::Airbrake
         | 
| 120 | 
            +
                              AIRBRAKE_VERSION = '5.0.0'
         | 
| 121 | 
            +
                            end
         | 
| 108 122 | 
             
                          end
         | 
| 109 | 
            -
                        end
         | 
| 110 123 |  | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 124 | 
            +
                          it 'notifies airbrake' do
         | 
| 125 | 
            +
                            expect(Airbrake).to receive(:notify).with(an_instance_of RuntimeError)
         | 
| 126 | 
            +
                            expect{ subject.consume { raise 'Consuming time' } }.not_to raise_error
         | 
| 127 | 
            +
                          end
         | 
| 114 128 | 
             
                        end
         | 
| 115 129 | 
             
                      end
         | 
| 116 | 
            -
                    end
         | 
| 117 130 |  | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 131 | 
            +
                      it 'negatively acknowledges the message' do
         | 
| 132 | 
            +
                        expect(bunny_channel).to receive(:nack)
         | 
| 133 | 
            +
                        subject.consume { raise 'Consuming time' }
         | 
| 134 | 
            +
                      end
         | 
| 121 135 | 
             
                    end
         | 
| 136 | 
            +
             | 
| 122 137 | 
             
                  end
         | 
| 123 138 | 
             
                end
         | 
| 124 139 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rabbit_feed
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.3. | 
| 4 | 
            +
              version: 2.3.10
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Simply Business
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016-02- | 
| 11 | 
            +
            date: 2016-02-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bunny
         |