Net::Stomp::MooseHelpers::ReconnectOnFailure - provide a reconnect-on-failure wrapper method
version 1.2
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 }
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.
connect_retry_delay
How many seconds to wait between connection attempts. Defaults to 15.
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.
$method
$self->
@args
First of all, this calls $self->connect(), then it calls $self->$method(@args), returning whatever it returns (preserves context).
$self->connect()
$self->$method(@args)
If an exception is raised, warns about it, sleeps for "connect_retry_delay" seconds, then tries again.
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
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.
To install Net::Stomp::MooseHelpers, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Stomp::MooseHelpers
CPAN shell
perl -MCPAN -e shell install Net::Stomp::MooseHelpers
For more information on module installation, please visit the detailed CPAN module installation guide.