Subscriber exits properly on possible authentication failures.
MODIFY
lib/beetle/subscriber.rb
lib/beetle/subscriber.rb
@@ -217,7 +217,8 @@ module Beetle
{
:host => current_host, :port => current_port, :logging => false,
:user => @client.config.user, :pass => @client.config.password, :vhost => @client.config.vhost,
- :on_tcp_connection_failure => on_tcp_connection_failure
+ :on_tcp_connection_failure => on_tcp_connection_failure,
+ :on_possible_authentication_failure => on_possible_authentication_failure,
}
end
@@ -228,6 +229,13 @@ module Beetle
end
end
+ def on_possible_authentication_failure
+ Proc.new do |settings|
+ logger.error "Beetle: possible authentication failure, or server overloaded: #{server_from_settings(settings)}. shutting down!"
+ stop!
+ end
+ end
+
def on_tcp_connection_loss(connection, settings)
# reconnect in 10 seconds, without enforcement
logger.warn "Beetle: lost connection: #{server_from_settings(settings)}. reconnecting."

MODIFY
test/beetle/subscriber_test.rb
test/beetle/subscriber_test.rb
@@ -428,6 +428,13 @@ module Beetle
cb.call(@settings)
end
+ test "possible authentication failure causes subscriber to exit" do
+ cb = @sub.send(:on_possible_authentication_failure)
+ @sub.expects(:stop!)
+ @sub.logger.expects(:error).with("Beetle: possible authentication failure, or server overloaded: mickey:42. shutting down!")
+ cb.call({:host => "mickey", :port => 42})
+ end
+
test "tcp connection loss handler tries to reconnect" do
connection = mock("connection")
connection.expects(:reconnect).with(false, 10)

Subscriber exits properly on possible authentication failures.