Twitter::API::Trait::RetryOnError - Automatically retry API calls on error
use Twitter::API;
my $client = Twitter::API->new_with_options(
traits => [ qw/ApiMethods RetryOnError/ ],
%other_optons
);
my $statuses = $client->home_timeline;
With this trait applied, Twitter::API automatically retries API calls that
result in an HTTP status code of 500 or greater. These errors often indicate a
temporary problem, either on Twitter's end, locally, or somewhere in between.
By default, it retries up to 5 times. The initial retry is delayed by 250ms.
Additional retries double the delay time until the maximum delay is reached
(default: 4 seconds). Twitter::API throws a
"Twitter::API::Error" exception when it
receives a permanent error (HTTP status code below 500), or the maximum number
of retries has been reached.
For non-blocking applications, set a suitable
"retry_delay_code" callback. This
attribute can also be used to provided retry logging.
Amount of time to delay before the initial retry. Specified in fractional
seconds. Default: 0.25 (250ms).
Maximum delay between retries, specified in fractional seconds. Default: 4.0.
After the initial delay, the delay time is multiplied by this factor to
progressively back off allowing more time for the transient condition to
resolve. However, the delay never exceeds
"max_retry_delay". Default: 2.0.
Maximum number of times to retry on error. Default: 5.
A coderef, called to implement a delay. It takes a single parameter, the number
of seconds to delay. E.g., 0.25. The default implementation is simply:
sub { Time::HiRes::sleep(shift) }
Marc Mims <marc@questright.com>
This software is copyright (c) 2015-2021 by Marc Mims.
This is free software; you can redistribute it and/or modify it
under the same terms as the Perl 5 programming language system itself.