make publisher connect timeout configurable
Beetle's disconnect timeout is still influenced by bunnies implementation
by multiplying the connect/disconnect timeout by 2 and adding 1.
MODIFY
lib/beetle/configuration.rb
lib/beetle/configuration.rb
@@ -89,6 +89,11 @@ module Beetle
# consider this a highly experimental feature for now.
attr_accessor :publishing_timeout
+ # the connect/disconnect timeout in seconds for the publishing connection
+ # (defaults to <tt>5</tt>).
+ # consider this a highly experimental feature for now.
+ attr_accessor :publisher_connect_timeout
+
# Prefetch count for subscribers (defaults to 1). Setting this higher
# than 1 can potentially increase throughput, but comes at the cost of
# decreased parallelism.
@@ -139,6 +144,7 @@ module Beetle
self.dead_lettering_read_timeout = 3 #3 seconds
self.publishing_timeout = 0
+ self.publisher_connect_timeout = 5
self.tmpdir = "/tmp"
self.log_file = STDOUT

MODIFY
lib/beetle/publisher.rb
lib/beetle/publisher.rb
@@ -2,9 +2,6 @@ module Beetle
# Provides the publishing logic implementation.
class Publisher < Base
- DEFAULT_BUNNY_CONNECT_TIMEOUT = 5
- DEFAULT_BEETLE_DISCONNECT_TIMEOUT = DEFAULT_BUNNY_CONNECT_TIMEOUT * 2 + 1
-
attr_reader :dead_servers
def initialize(client, options = {}) #:nodoc:
@@ -171,7 +168,7 @@ module Beetle
:frame_max => @client.config.frame_max,
:channel_max => @client.config.channel_max,
:socket_timeout => @client.config.publishing_timeout,
- :connect_timeout => DEFAULT_BUNNY_CONNECT_TIMEOUT,
+ :connect_timeout => @client.config.publisher_connect_timeout,
:spec => '09')
b.start
b
@@ -228,7 +225,8 @@ module Beetle
def stop!(exception=nil)
return unless bunny?
- Beetle::Timer.timeout(DEFAULT_BEETLE_DISCONNECT_TIMEOUT) do
+ timeout = @client.config.publisher_connect_timeout * 2 + 1
+ Beetle::Timer.timeout(timeout) do
logger.debug "Beetle: closing connection from publisher to #{server}"
if exception
bunny.__send__ :close_socket

make publisher connect timeout configurable

Beetle's disconnect timeout is still influenced by bunnies implementation
by multiplying the connect/disconnect timeout by 2 and adding 1.