Net::Twitter::Role::RetryOnError - Retry Twitter API calls on error
version 4.00006
use Net::Twitter; $nt = Net::Twitter->new( traits => ['API::RESTv1_1', 'RetryOnError'] max_retries => 3, );
Temporary errors are not uncommon when calling the Twitter API. When applied to Net::Twitter this role will provide automatic retries of API calls in a very configurable way.
It only retries when the response status code is >= 500. Other error codes indicate a permanent error. If the maximum number of retries is reached, without success, an exception is thrown, as usual.
This role adds the following options to new:
new
A floating point number specifying the initial delay, after an error, before retrying. Default: 0.25 (250 milliseconds).
A floating point number specifying the maximum delay between retries. Default: 4.0
On the second and subsequent retries, a new delay is calculated by multiplying the previous delay by retry_delay_multiplier. Default: 2.0
retry_delay_multiplier
The maximum number of consecutive retries before giving up and throwing an exception. If set to 0, it the API call will be retried indefinitely. Default 5.
A code reference that will be called to handle the delay. It is passed a single argument: a floating point number specifying the number of seconds to delay. By default, "sleep" in Time::HiRes is called.
If you're using a non-blocking user agent, like Coro::LWP, you should use this option to provide a non-blocking delay.
Marc Mims <marc@questright.com>
Copyright (c) 2010 Marc Mims
This library is free software and may be distributed under the same terms as perl itself.
To install Net::Twitter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Twitter
CPAN shell
perl -MCPAN -e shell install Net::Twitter
For more information on module installation, please visit the detailed CPAN module installation guide.