action_subscriber 2.5.0.pre → 2.5.0.pre2
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/.travis.yml +1 -2
- data/lib/action_subscriber.rb +1 -0
- data/lib/action_subscriber/bunny/subscriber.rb +4 -0
- data/lib/action_subscriber/march_hare/subscriber.rb +6 -0
- data/lib/action_subscriber/route_set.rb +7 -1
- data/lib/action_subscriber/synchronizer.rb +15 -0
- data/lib/action_subscriber/version.rb +1 -1
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 85dc20de7aa4e917f499156bb94d4b2e40b9ed12
         | 
| 4 | 
            +
              data.tar.gz: 7f34bea3b45e1e230cbc55e4e432540094c6241a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c2b3f863edc1609bc43f403b519cb05c62a7b4dc7e7b8f2048d076fdb7d4523271bd742e3006f67e50b34360c2ac357dc773771e1e0b6d321450e941effed54f
         | 
| 7 | 
            +
              data.tar.gz: a4261aa2255ad0eb865a1d3e64b0249ea0fac3b91a103301f337ca715777913ff7e1e2a1fe13b6f69a2b2cfcf1bc2d8fb87018c0653fc2ec0e73738cda6e594c
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/lib/action_subscriber.rb
    CHANGED
    
    | @@ -27,6 +27,7 @@ require "action_subscriber/march_hare/subscriber" | |
| 27 27 | 
             
            require "action_subscriber/babou"
         | 
| 28 28 | 
             
            require "action_subscriber/publisher"
         | 
| 29 29 | 
             
            require "action_subscriber/publisher/async"
         | 
| 30 | 
            +
            require "action_subscriber/synchronizer"
         | 
| 30 31 | 
             
            require "action_subscriber/route"
         | 
| 31 32 | 
             
            require "action_subscriber/route_set"
         | 
| 32 33 | 
             
            require "action_subscriber/router"
         | 
| @@ -11,6 +11,10 @@ module ActionSubscriber | |
| 11 11 | 
             
                    bunny_consumers.each(&:cancel)
         | 
| 12 12 | 
             
                  end
         | 
| 13 13 |  | 
| 14 | 
            +
                  def create_queue(channel, queue_name, queue_options)
         | 
| 15 | 
            +
                    ::Bunny::Queue.new(channel, queue_name, queue_options)
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 14 18 | 
             
                  def auto_pop!
         | 
| 15 19 | 
             
                    # Because threadpools can be large we want to cap the number
         | 
| 16 20 | 
             
                    # of times we will pop each time we poll the broker
         | 
| @@ -7,6 +7,12 @@ module ActionSubscriber | |
| 7 7 | 
             
                    march_hare_consumers.each(&:cancel)
         | 
| 8 8 | 
             
                  end
         | 
| 9 9 |  | 
| 10 | 
            +
                  def create_queue(channel, queue_name, queue_options)
         | 
| 11 | 
            +
                    queue = ::MarchHare::Queue.new(channel, queue_name, queue_options)
         | 
| 12 | 
            +
                    queue.declare!
         | 
| 13 | 
            +
                    queue
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 10 16 | 
             
                  def auto_pop!
         | 
| 11 17 | 
             
                    # Because threadpools can be large we want to cap the number
         | 
| 12 18 | 
             
                    # of times we will pop each time we poll the broker
         | 
| @@ -26,8 +26,14 @@ module ActionSubscriber | |
| 26 26 |  | 
| 27 27 | 
             
                def setup_queue(route)
         | 
| 28 28 | 
             
                  channel = ::ActionSubscriber::RabbitConnection.subscriber_connection.create_channel
         | 
| 29 | 
            +
                  # Make channels threadsafe again! Believe Me!
         | 
| 30 | 
            +
                  # Accessing channels from multiple threads for messsage acknowledgement will crash
         | 
| 31 | 
            +
                  # a channel and stop messages from being received on that channel
         | 
| 32 | 
            +
                  # this isn't very clear in the documentation for march_hare/bunny, but it is
         | 
| 33 | 
            +
                  # explicitly addresses here: https://github.com/rabbitmq/rabbitmq-java-client/issues/53
         | 
| 34 | 
            +
                  channel = ::ActionSubscriber::Synchronizer.new(channel)
         | 
| 29 35 | 
             
                  exchange = channel.topic(route.exchange)
         | 
| 30 | 
            -
                  queue = channel | 
| 36 | 
            +
                  queue = create_queue(channel, route.queue, :durable => route.durable)
         | 
| 31 37 | 
             
                  queue.bind(exchange, :routing_key => route.routing_key)
         | 
| 32 38 | 
             
                  queue
         | 
| 33 39 | 
             
                end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require "thread"
         | 
| 2 | 
            +
            module ActionSubscriber
         | 
| 3 | 
            +
              class Synchronizer
         | 
| 4 | 
            +
                def initialize(delegate)
         | 
| 5 | 
            +
                  @delegate = delegate
         | 
| 6 | 
            +
                  @mutex = ::Mutex.new
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def method_missing(name, *args, &block)
         | 
| 10 | 
            +
                  @mutex.synchronize do
         | 
| 11 | 
            +
                    @delegate.public_send(name, *args, &block)
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: action_subscriber
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.5.0. | 
| 4 | 
            +
              version: 2.5.0.pre2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Brian Stien
         | 
| @@ -12,7 +12,7 @@ authors: | |
| 12 12 | 
             
            autorequire: 
         | 
| 13 13 | 
             
            bindir: bin
         | 
| 14 14 | 
             
            cert_chain: []
         | 
| 15 | 
            -
            date: 2016-09- | 
| 15 | 
            +
            date: 2016-09-12 00:00:00.000000000 Z
         | 
| 16 16 | 
             
            dependencies:
         | 
| 17 17 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 18 18 | 
             
              name: activesupport
         | 
| @@ -224,6 +224,7 @@ files: | |
| 224 224 | 
             
            - lib/action_subscriber/router.rb
         | 
| 225 225 | 
             
            - lib/action_subscriber/rspec.rb
         | 
| 226 226 | 
             
            - lib/action_subscriber/subscribable.rb
         | 
| 227 | 
            +
            - lib/action_subscriber/synchronizer.rb
         | 
| 227 228 | 
             
            - lib/action_subscriber/threadpool.rb
         | 
| 228 229 | 
             
            - lib/action_subscriber/uri.rb
         | 
| 229 230 | 
             
            - lib/action_subscriber/version.rb
         | 
| @@ -277,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 277 278 | 
             
                  version: 1.3.1
         | 
| 278 279 | 
             
            requirements: []
         | 
| 279 280 | 
             
            rubyforge_project: 
         | 
| 280 | 
            -
            rubygems_version: 2. | 
| 281 | 
            +
            rubygems_version: 2.6.6
         | 
| 281 282 | 
             
            signing_key: 
         | 
| 282 283 | 
             
            specification_version: 4
         | 
| 283 284 | 
             
            summary: ActionSubscriber is a DSL that allows a rails app to consume messages from
         |