[Redis] Redis client: Timeouts !

Damien Krotkine dkrotkine at gmail.com
Fri Dec 27 18:14:11 GMT 2013



On Fri, Dec 27, 2013, at 08:02 AM, Steffen Mueller wrote:
> On 12/27/2013 10:23 AM, Damien Krotkine wrote:
> >
> > Ithere is a better way, I'd be happy to change the implementation.
> 
> FWIW, I would take an ugly interface over a cute, but subtle and/or
> intrusive interface any day.

I'm thinking about other APIs.

1/ Maybe something more role-esque, on the instance. Something like
my $socket = IO::Socket::Timeout->on(IO::Socket::INET->new(Timeout =>
2), ReadTimeout => 0.2 );
The drawback is that Timeout (connection timeout) has to be passed to
the *new()*, whereas the read / write timeouts have to be set outside of
it, in the *on()* params. Ugly.

2/ Or directly adding new_with_timeout on the IO::Socket base class. I
thought that would be considered too intrusive, but maybe it's not.

3/ Or not going the OO way and just export read_timeout() and
write_timeout(), and let people instantiate their $socket, then
read_timeout($socket, 0.5); Maybe that's the best ratio between nice API
and non-hackish implementation. I initially thought that people would
like to change the timeouts a lot during the socket lifetime, but now I
don't think that anyone cares about that, so having read_timeout() and
others functions as methods is actually not adding value. So yeah, maybe
this non-OO API is the best one.

I'll change that soon.

dams.




More information about the Redis mailing list