Default to one-second connect timeout for Redis
This commit is contained in:
parent
42c551944e
commit
15a297372d
@ -352,6 +352,7 @@ sub db_args {
|
||||
$self->validate_db_args(@_);
|
||||
$self->{db_args} = \%arg if %arg;
|
||||
$self->{db_args}{name} ||= $self->plugin_name;
|
||||
$self->{db_args}{cnx_timeout} ||= 1;
|
||||
return %{ $self->{db_args} };
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,9 @@ Location of redis server where the greylisting DB will be stored.
|
||||
Redis can be used as a scalable and clusterable alternative
|
||||
to a simple DBM file. For more information, see http://redis.io
|
||||
|
||||
When Redis is in use, this plugin will wait up to 1 second to connect;
|
||||
when Redis is unavailable, clients will not be greylisted.
|
||||
|
||||
=head2 per_recipient <bool>
|
||||
|
||||
Flag to indicate whether to use per-recipient configs.
|
||||
|
@ -338,7 +338,8 @@ sub test_init_redis {
|
||||
$self->{_args}{redis} = 'testredis';
|
||||
$self->init_db;
|
||||
is( keyvals($self->db_args),
|
||||
'class=Qpsmtpd::DB::Redis;name=greylist;server=testredis:6379',
|
||||
'class=Qpsmtpd::DB::Redis;cnx_timeout=1;'
|
||||
. 'name=greylist;server=testredis:6379',
|
||||
'init_redis() sets redis args' );
|
||||
}
|
||||
|
||||
|
@ -27,16 +27,16 @@ sub __validate_db_args {
|
||||
sub __db_args {
|
||||
my $plugin = FakePlugin->new;
|
||||
is( keyvals($plugin->db_args),
|
||||
'name=___MockHook___',
|
||||
'cnx_timeout=1;name=___MockHook___',
|
||||
'default db args populated' );
|
||||
is( keyvals($plugin->db_args( arg1 => 1 )),
|
||||
'arg1=1;name=___MockHook___',
|
||||
'arg1=1;cnx_timeout=1;name=___MockHook___',
|
||||
'passed args in addition to defaults' );
|
||||
is( keyvals($plugin->db_args( name => 'bob', arg2 => 2 )),
|
||||
'arg2=2;name=bob',
|
||||
'arg2=2;cnx_timeout=1;name=bob',
|
||||
'passed args override defaults' );
|
||||
is( keyvals($plugin->db_args),
|
||||
'arg2=2;name=bob',
|
||||
'arg2=2;cnx_timeout=1;name=bob',
|
||||
'get previous args' );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user