Add support for requeue_delay on constructors, used on REQ responses

Signed-off-by: Pedro Melo <melo@simplicidade.org>
This commit is contained in:
Pedro Melo
2014-07-20 17:34:31 +01:00
parent dcca4aea33
commit be7b2c03d6
2 changed files with 7 additions and 4 deletions

View File

@@ -14,7 +14,6 @@ use Sys::Hostname;
# Options from the python client, we might want to support later:
# timeout=1.0
# heartbeat_interval=30
# requeue_delay=90
# tls_v1=False
# tls_options=None
# snappy=False
@@ -25,15 +24,19 @@ use Sys::Hostname;
# sample_rate=0
# auth_secret=None
## Constructor
sub new {
my ($class, %args) = @_;
my $self = bless(
{ hostname => hostname(),
connect_timeout => undef, ## use kernel default
error_cb => sub {
croak(qq{FATAL: error from host '$_[0]->{host}' port $_[0]->{port}: $_[1]});
},
connect_timeout => undef, ## use kernel default
requeue_delay => 90,
},
$class
);

View File

@@ -22,7 +22,7 @@ sub new {
$self->{disconnect_cb} = delete($args{disconnect_cb}) || sub { };
$self->{error_cb} = delete($args{error_cb}) || sub { croak($_[1]) };
for my $arg (qw( ready_count client_id hostname )) {
for my $arg (qw( ready_count client_id hostname requeue_delay )) {
$self->{$arg} = delete($args{$arg}) if exists $args{$arg};
}
@@ -79,7 +79,7 @@ sub _start_nsqd_connection {
croak(qq{FATAL: could not parse '$nsqd_tcp_address' as a valid address/port combination}) unless $host and $port;
my %conn = (host => $host, port => $port);
for my $arg (qw( client_id hostname error_cb )) {
for my $arg (qw( client_id hostname error_cb requeue_delay )) {
$conn{$arg} = $self->{$arg} if exists $self->{$arg};
}