NAME
Net::Stomp::MooseHelpers::ReconnectOnFailure - provide a reconnect-on-failure wrapper method
VERSION
version 2.2
SYNOPSIS
package MyThing;
use Moose;
with 'Net::Stomp::MooseHelpers::CanConnect';
with 'Net::Stomp::MooseHelpers::ReconnectOnFailure';
sub foo {
my ($self) = @_;
$self->reconnect_on_failure('connect');
# do something
}
DESCRIPTION
This role wraps the logic shown in the synopsis for Net::Stomp::MooseHelpers::CanConnect into a simple wrapper method.
Just call "reconnect_on_failure" passing the method name (or a coderef) and all the arguments. See below for details.
ATTRIBUTES
connect_retry_delay
How many seconds to wait between connection attempts. Defaults to 15.
METHODS
reconnect_on_failure
$self->reconnect_on_failure($method,@args);
$method
can be a method name or a coderef (anything that you'd write just after $self->
). @args
are passed untouched.
First of all, this calls $self->connect()
, then it calls $self->$method(@args)
, returning whatever it returns (preserves context).
If an exception is raised, warns about it, sleeps for "connect_retry_delay" seconds, then tries again.
AUTHOR
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Net-a-porter.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.