logstash-mixin-rabbitmq_connection 1.0.0.beta1-java
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 +7 -0
 - data/.gitignore +6 -0
 - data/Gemfile +2 -0
 - data/README.md +4 -0
 - data/lib/logstash/plugin_mixins/rabbitmq_connection.rb +147 -0
 - data/logstash-mixin-rabbitmq_connection.gemspec +29 -0
 - data/spec/plugin_mixins/rabbitmq_connection_spec.rb +102 -0
 - metadata +127 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: be261e8112ff1e011b6191a7440ae5cb8850220b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: cd9acfffc0d2ead393dc9c952373bba3d663e52b
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ca50bdcf451390ee94103af05253eecb613b96ae5872e0f893e68cb7dce684c8d3fd9e62ba207d6ce5456be18e532a4bbb58e740d143377a976241309f92e1ae
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b552fae802db33fbf7ff6a4b79d22149c27dda4942acb71b4eaeb5111d6ebd2f7eb0d29732b24d1275196bc54b6377e9ccb0acb36526a31f7591de8e44fb147b
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/README.md
    ADDED
    
    
| 
         @@ -0,0 +1,147 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "logstash/outputs/base"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "logstash/namespace"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "march_hare"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "java"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            # Common functionality for the rabbitmq input/output
         
     | 
| 
      
 8 
     | 
    
         
            +
            module LogStash
         
     | 
| 
      
 9 
     | 
    
         
            +
              module PluginMixins
         
     | 
| 
      
 10 
     | 
    
         
            +
                module RabbitMQConnection
         
     | 
| 
      
 11 
     | 
    
         
            +
                  EXCHANGE_TYPES = ["fanout", "direct", "topic"]
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  HareInfo = Struct.new(:connection, :channel, :exchange, :queue)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def self.included(base)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    base.extend(self)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    base.setup_rabbitmq_connection_config
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def setup_rabbitmq_connection_config
         
     | 
| 
      
 21 
     | 
    
         
            +
                    # RabbitMQ server address
         
     | 
| 
      
 22 
     | 
    
         
            +
                    config :host, :validate => :string, :required => true
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    # RabbitMQ port to connect on
         
     | 
| 
      
 25 
     | 
    
         
            +
                    config :port, :validate => :number, :default => 5672
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    # RabbitMQ username
         
     | 
| 
      
 28 
     | 
    
         
            +
                    config :user, :validate => :string, :default => "guest"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    # RabbitMQ password
         
     | 
| 
      
 31 
     | 
    
         
            +
                    config :password, :validate => :password, :default => "guest"
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    # The vhost to use. If you don't know what this is, leave the default.
         
     | 
| 
      
 34 
     | 
    
         
            +
                    config :vhost, :validate => :string, :default => "/"
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    # Enable or disable SSL
         
     | 
| 
      
 37 
     | 
    
         
            +
                    config :ssl, :validate => :boolean, :default => false
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    # Validate SSL certificate
         
     | 
| 
      
 40 
     | 
    
         
            +
                    config :verify_ssl, :validate => :boolean, :default => false
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                    # Enable or disable logging
         
     | 
| 
      
 43 
     | 
    
         
            +
                    config :debug, :validate => :boolean, :default => false, :deprecated => "Use the logstash --debug flag for this instead."
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    # Set this to automatically recover from a broken connection. You almost certainly don't want to override this!!!
         
     | 
| 
      
 46 
     | 
    
         
            +
                    config :automatic_recovery, :validate => :boolean, :default => true
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    # Time in seconds to wait before retrying a connection
         
     | 
| 
      
 49 
     | 
    
         
            +
                    config :connect_retry_interval, :validate => :number, :default => 1
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                    # Passive queue creation? Useful for checking queue existance without modifying server state
         
     | 
| 
      
 52 
     | 
    
         
            +
                    config :passive, :validate => :boolean, :default => false
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    # Extra queue arguments as an array.
         
     | 
| 
      
 55 
     | 
    
         
            +
                    # To make a RabbitMQ queue mirrored, use: `{"x-ha-policy" => "all"}`
         
     | 
| 
      
 56 
     | 
    
         
            +
                    config :arguments, :validate => :array, :default => {}
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  def conn_str
         
     | 
| 
      
 61 
     | 
    
         
            +
                    "amqp://#{@user}@#{@host}:#{@port}#{@vhost}"
         
     | 
| 
      
 62 
     | 
    
         
            +
                  end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                  def teardown
         
     | 
| 
      
 65 
     | 
    
         
            +
                    @hare_info.channel.close if channel_open?
         
     | 
| 
      
 66 
     | 
    
         
            +
                    @hare_info.connection.close if connection_open?
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                    finished
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                  def rabbitmq_settings
         
     | 
| 
      
 72 
     | 
    
         
            +
                    return @rabbitmq_settings if @rabbitmq_settings
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    s = {
         
     | 
| 
      
 75 
     | 
    
         
            +
                      :vhost => @vhost,
         
     | 
| 
      
 76 
     | 
    
         
            +
                      :host  => @host,
         
     | 
| 
      
 77 
     | 
    
         
            +
                      :port  => @port,
         
     | 
| 
      
 78 
     | 
    
         
            +
                      :user  => @user,
         
     | 
| 
      
 79 
     | 
    
         
            +
                      :automatic_recovery => @automatic_recovery,
         
     | 
| 
      
 80 
     | 
    
         
            +
                      :pass => @password ? @password.value : "guest",
         
     | 
| 
      
 81 
     | 
    
         
            +
                    }
         
     | 
| 
      
 82 
     | 
    
         
            +
                    s[:tls] = @ssl if @ssl
         
     | 
| 
      
 83 
     | 
    
         
            +
                    @rabbitmq_settings = s
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                  def connect!
         
     | 
| 
      
 87 
     | 
    
         
            +
                    @hare_info = connect() unless @hare_info # Don't duplicate the conn!
         
     | 
| 
      
 88 
     | 
    
         
            +
                  rescue MarchHare::Exception => e
         
     | 
| 
      
 89 
     | 
    
         
            +
                    return if terminating?
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                    @logger.error("RabbitMQ connection error, will retry.",
         
     | 
| 
      
 92 
     | 
    
         
            +
                                  :message => e.message,
         
     | 
| 
      
 93 
     | 
    
         
            +
                                  :exception => e.class.name,
         
     | 
| 
      
 94 
     | 
    
         
            +
                                  :backtrace => e.backtrace)
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                    sleep_for_retry
         
     | 
| 
      
 97 
     | 
    
         
            +
                    retry
         
     | 
| 
      
 98 
     | 
    
         
            +
                  end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                  def channel_open?
         
     | 
| 
      
 101 
     | 
    
         
            +
                    @hare_info && @hare_info.channel && @hare_info.channel.open?
         
     | 
| 
      
 102 
     | 
    
         
            +
                  end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                  def connection_open?
         
     | 
| 
      
 105 
     | 
    
         
            +
                    @hare_info && @hare_info.connection && @hare_info.connection.open?
         
     | 
| 
      
 106 
     | 
    
         
            +
                  end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                  def connected?
         
     | 
| 
      
 109 
     | 
    
         
            +
                    return nil unless @hare_info && @hare_info.connection
         
     | 
| 
      
 110 
     | 
    
         
            +
                    @hare_info.connection.connected?
         
     | 
| 
      
 111 
     | 
    
         
            +
                  end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                  private
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                  def declare_exchange!(channel, exchange, exchange_type, durable)
         
     | 
| 
      
 116 
     | 
    
         
            +
                    @logger.debug("Declaring an exchange", :name => exchange,
         
     | 
| 
      
 117 
     | 
    
         
            +
                                  :type => exchange_type, :durable => durable)
         
     | 
| 
      
 118 
     | 
    
         
            +
                    exchange = channel.exchange(exchange, :type => exchange_type.to_sym, :durable => durable)
         
     | 
| 
      
 119 
     | 
    
         
            +
                    @logger.debug("Exchange declared")
         
     | 
| 
      
 120 
     | 
    
         
            +
                    exchange
         
     | 
| 
      
 121 
     | 
    
         
            +
                  rescue StandardError => e
         
     | 
| 
      
 122 
     | 
    
         
            +
                    @logger.error("Could not declare exchange!",
         
     | 
| 
      
 123 
     | 
    
         
            +
                                  :exchange => exchange, :type => exchange_type,
         
     | 
| 
      
 124 
     | 
    
         
            +
                                  :durable => durable, :error_class => e.class.name,
         
     | 
| 
      
 125 
     | 
    
         
            +
                                  :error_message => e.message, :backtrace => e.backtrace)
         
     | 
| 
      
 126 
     | 
    
         
            +
                    raise e
         
     | 
| 
      
 127 
     | 
    
         
            +
                  end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                  def connect
         
     | 
| 
      
 130 
     | 
    
         
            +
                    @logger.debug? && @logger.debug("Connecting to RabbitMQ. Settings: #{rabbitmq_settings.inspect}")
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                    connection = MarchHare.connect(rabbitmq_settings)
         
     | 
| 
      
 133 
     | 
    
         
            +
                    connection.on_blocked { @logger.warn("RabbitMQ output blocked! Check your RabbitMQ instance!") }
         
     | 
| 
      
 134 
     | 
    
         
            +
                    connection.on_unblocked { @logger.warn("RabbitMQ output unblocked!") }
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                    channel = connection.create_channel
         
     | 
| 
      
 137 
     | 
    
         
            +
                    @logger.info("Connected to RabbitMQ at #{rabbitmq_settings[:host]}")
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                    HareInfo.new(connection, channel)
         
     | 
| 
      
 140 
     | 
    
         
            +
                  end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                  def sleep_for_retry
         
     | 
| 
      
 143 
     | 
    
         
            +
                    sleep @connect_retry_interval
         
     | 
| 
      
 144 
     | 
    
         
            +
                  end
         
     | 
| 
      
 145 
     | 
    
         
            +
                end
         
     | 
| 
      
 146 
     | 
    
         
            +
              end
         
     | 
| 
      
 147 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              s.name            = 'logstash-mixin-rabbitmq_connection'
         
     | 
| 
      
 4 
     | 
    
         
            +
              s.version         = '1.0.0.beta1'
         
     | 
| 
      
 5 
     | 
    
         
            +
              s.licenses        = ['Apache License (2.0)']
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.summary         = "Common functionality for RabbitMQ plugins"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.description     = "This is used to provide configuration options and connection settings for logstash plugins working with RabbitMQ"
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.authors         = ["Elastic"]
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.email           = 'info@elastic.co'
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.homepage        = "http://www.elastic.co/guide/en/logstash/current/index.html"
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              # Files
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              # Tests
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.test_files = s.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              # Gem dependencies
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              s.platform = RUBY_PLATFORM
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.add_runtime_dependency 'march_hare', ['~> 2.11.0'] #(MIT license)
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              s.add_development_dependency 'logstash-devutils'
         
     | 
| 
      
 26 
     | 
    
         
            +
              s.add_development_dependency 'logstash-input-generator'
         
     | 
| 
      
 27 
     | 
    
         
            +
              s.add_development_dependency 'logstash-codec-json'
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,102 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "logstash/devutils/rspec/spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "logstash/pipeline"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "logstash/plugin_mixins/rabbitmq_connection"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class TestPlugin < LogStash::Outputs::Base
         
     | 
| 
      
 6 
     | 
    
         
            +
              include LogStash::PluginMixins::RabbitMQConnection
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              def register
         
     | 
| 
      
 9 
     | 
    
         
            +
                connect!
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            describe LogStash::PluginMixins::RabbitMQConnection do
         
     | 
| 
      
 14 
     | 
    
         
            +
              let(:klass) { TestPlugin }
         
     | 
| 
      
 15 
     | 
    
         
            +
              let(:host) { "localhost" }
         
     | 
| 
      
 16 
     | 
    
         
            +
              let(:port) { 5672 }
         
     | 
| 
      
 17 
     | 
    
         
            +
              let(:rabbitmq_settings) {
         
     | 
| 
      
 18 
     | 
    
         
            +
                {
         
     | 
| 
      
 19 
     | 
    
         
            +
                  "host" => host,
         
     | 
| 
      
 20 
     | 
    
         
            +
                  "port" => port,
         
     | 
| 
      
 21 
     | 
    
         
            +
                }
         
     | 
| 
      
 22 
     | 
    
         
            +
              }
         
     | 
| 
      
 23 
     | 
    
         
            +
              let(:instance) {
         
     | 
| 
      
 24 
     | 
    
         
            +
                klass.new(rabbitmq_settings)
         
     | 
| 
      
 25 
     | 
    
         
            +
              }
         
     | 
| 
      
 26 
     | 
    
         
            +
              let(:hare_info) { instance.instance_variable_get(:@hare_info) }
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              context "when connected" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                let(:connection) { double("MarchHare Connection") }
         
     | 
| 
      
 30 
     | 
    
         
            +
                let(:channel) { double("Channel") }
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                before do
         
     | 
| 
      
 33 
     | 
    
         
            +
                  allow(instance).to receive(:connect!).and_call_original
         
     | 
| 
      
 34 
     | 
    
         
            +
                  allow(::MarchHare).to receive(:connect).and_return(connection)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  allow(connection).to receive(:create_channel).and_return(channel)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  allow(connection).to receive(:on_blocked)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  allow(connection).to receive(:on_unblocked)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  instance.register
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                describe "#register" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  subject { instance }
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  it "should create cleanly" do
         
     | 
| 
      
 46 
     | 
    
         
            +
                    expect(subject).to be_a(klass)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  it "should connect" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                    expect(subject).to have_received(:connect!).once
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                describe "#connect!" do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  subject { hare_info }
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  it "should set @hare_info correctly" do
         
     | 
| 
      
 58 
     | 
    
         
            +
                    expect(subject).to be_a(LogStash::PluginMixins::RabbitMQConnection::HareInfo)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  it "should set @connection correctly" do
         
     | 
| 
      
 62 
     | 
    
         
            +
                    expect(subject.connection).to eql(connection)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  it "should set the channel correctly" do
         
     | 
| 
      
 66 
     | 
    
         
            +
                    expect(subject.channel).to eql(channel)
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              # If the connection encounters an exception during its initial
         
     | 
| 
      
 72 
     | 
    
         
            +
              # connection attempt we must handle that. Subsequent errors should be
         
     | 
| 
      
 73 
     | 
    
         
            +
              # handled by the automatic retry mechanism built-in to MarchHare
         
     | 
| 
      
 74 
     | 
    
         
            +
              describe "initial connection exceptions" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                subject { instance }
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                before do
         
     | 
| 
      
 78 
     | 
    
         
            +
                  allow(subject).to receive(:sleep_for_retry)
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  i = 0
         
     | 
| 
      
 82 
     | 
    
         
            +
                  allow(subject).to receive(:connect) do
         
     | 
| 
      
 83 
     | 
    
         
            +
                    i += 1
         
     | 
| 
      
 84 
     | 
    
         
            +
                    if i == 1
         
     | 
| 
      
 85 
     | 
    
         
            +
                      raise(MarchHare::ConnectionRefused, "Error!")
         
     | 
| 
      
 86 
     | 
    
         
            +
                    else
         
     | 
| 
      
 87 
     | 
    
         
            +
                      double("connection")
         
     | 
| 
      
 88 
     | 
    
         
            +
                    end
         
     | 
| 
      
 89 
     | 
    
         
            +
                  end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                  subject.send(:connect!)
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                it "should retry its connection when conn fails" do
         
     | 
| 
      
 95 
     | 
    
         
            +
                  expect(subject).to have_received(:connect).twice
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                it "should sleep between retries" do
         
     | 
| 
      
 99 
     | 
    
         
            +
                  expect(subject).to have_received(:sleep_for_retry).once
         
     | 
| 
      
 100 
     | 
    
         
            +
                end
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,127 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: logstash-mixin-rabbitmq_connection
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0.beta1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: java
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Elastic
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-09-17 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 15 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 16 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 17 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 18 
     | 
    
         
            +
                    version: 1.4.0
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
      
 22 
     | 
    
         
            +
              name: logstash-core
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 25 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: 1.4.0
         
     | 
| 
      
 30 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 31 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
      
 33 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 34 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 35 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 36 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 37 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 38 
     | 
    
         
            +
                    version: 2.11.0
         
     | 
| 
      
 39 
     | 
    
         
            +
              name: march_hare
         
     | 
| 
      
 40 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 41 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 42 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 43 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 44 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 45 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 46 
     | 
    
         
            +
                    version: 2.11.0
         
     | 
| 
      
 47 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 48 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 50 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 51 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 52 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 53 
     | 
    
         
            +
              name: logstash-devutils
         
     | 
| 
      
 54 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 55 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 56 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 57 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 58 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 59 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 60 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 61 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 62 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 63 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 64 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 65 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 66 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 67 
     | 
    
         
            +
              name: logstash-input-generator
         
     | 
| 
      
 68 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 69 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 70 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 71 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 72 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 73 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 74 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 75 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 76 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 77 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 78 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 79 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 80 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 81 
     | 
    
         
            +
              name: logstash-codec-json
         
     | 
| 
      
 82 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 83 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 84 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 85 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 86 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 87 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 88 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 89 
     | 
    
         
            +
            description: This is used to provide configuration options and connection settings for logstash plugins working with RabbitMQ
         
     | 
| 
      
 90 
     | 
    
         
            +
            email: info@elastic.co
         
     | 
| 
      
 91 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 92 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 93 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 94 
     | 
    
         
            +
            files:
         
     | 
| 
      
 95 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 96 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 97 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 98 
     | 
    
         
            +
            - lib/logstash/plugin_mixins/rabbitmq_connection.rb
         
     | 
| 
      
 99 
     | 
    
         
            +
            - logstash-mixin-rabbitmq_connection.gemspec
         
     | 
| 
      
 100 
     | 
    
         
            +
            - spec/plugin_mixins/rabbitmq_connection_spec.rb
         
     | 
| 
      
 101 
     | 
    
         
            +
            homepage: http://www.elastic.co/guide/en/logstash/current/index.html
         
     | 
| 
      
 102 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 103 
     | 
    
         
            +
            - Apache License (2.0)
         
     | 
| 
      
 104 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 105 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
      
 106 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 107 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 108 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 109 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 110 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 111 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 112 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 113 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 114 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 115 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 116 
     | 
    
         
            +
              - - ">"
         
     | 
| 
      
 117 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 118 
     | 
    
         
            +
                  version: 1.3.1
         
     | 
| 
      
 119 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 120 
     | 
    
         
            +
            rubyforge_project:
         
     | 
| 
      
 121 
     | 
    
         
            +
            rubygems_version: 2.4.8
         
     | 
| 
      
 122 
     | 
    
         
            +
            signing_key:
         
     | 
| 
      
 123 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 124 
     | 
    
         
            +
            summary: Common functionality for RabbitMQ plugins
         
     | 
| 
      
 125 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 126 
     | 
    
         
            +
            - spec/plugin_mixins/rabbitmq_connection_spec.rb
         
     | 
| 
      
 127 
     | 
    
         
            +
            has_rdoc:
         
     |