Net::T...nError(3pm)

πŸ“¦
version 4.01043 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble

πŸ’– NAME πŸ’–

Net::Twitter::Role::RetryOnError β€” bestie, this is the role that says "okay that call failed but like… try again?" to the Twitter API πŸ¦‹


✨ VERSION ✨

version 4.01043 β€” yes she's got a number and she's proud of it πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

use Net::Twitter;
$nt = Net::Twitter->new(
    traits      => ['API::RESTv1_1', 'RetryOnError']
    max_retries => 3,
);

look at her go. literally just plug the trait in and let her cook πŸ“


🌸 DESCRIPTION 🌸

okay so real talk: calling the Twitter API, temporary errors just happen. not a vibe, not your fault, just the universe being messy 😭. Slap this role onto Net::Twitter and you get automatic retries of your API calls, and it's super configurable β€” you're the main character here, you decide everything.

The way that it only retries when the response status code is >= 500?? That's the whole rule. Any other error code is giving permanent error, so she won't waste your time retrying it, periodt. And if she hits the maximum number of retries and still hasn't succeeded? An exception gets thrown, as usual. No cap, that's just how it is πŸ’€


πŸ”₯ OPTIONS πŸ”₯

This role adds these options to new, so go off bestie:

  • initial_retry_delay β€” a floating point number, it's the initial delay after an error and before retrying. Default: 0.25 (that's 250 milliseconds, iykyk ⏱️)
  • max_retry_delay β€” a floating point number, the maximum delay between retries. Default: 4.0
  • retry_delay_multiplier β€” on the second retry and every one after that, a new delay gets calculated by multiplying the previous delay by retry_delay_multiplier. Default: 2.0 (she grows fast 🌱)
  • max_retries β€” the maximum number of consecutive retries before she gives up and throws an exception. And listen: if you set it to 0, the API call will be retried indefinitely πŸ™ˆ. Default 5.
  • retry_delay_code β€” a code reference that gets called to handle the delay. She's passed a single argument: a floating point number with the number of seconds to delay. By default, sleep in Time::HiRes is called.
real talk for the async girlies: if you're using a non-blocking user agent, like Coro::LWP, you should use this option to provide a non-blocking delay. don't block the whole vibe βœ‹

πŸ‘‘ AUTHOR πŸ‘‘

Marc Mims <marc@questright.com> β€” icon, legend, the moment πŸ’œ


Copyright (c) 2016 Marc Mims


πŸ’œ LICENSE πŸ’œ

This library is free software and may be distributed under the same terms as perl itself. slay, share her with the world 🫢


and that's the whole page bestie!! she's from perl v5.34.0, dated 2022-06-16, and her manual name is Net::T...nError(3pm) β€” go forth and retry responsibly βœ¨πŸŽ€

πŸ“¦ where this page comes from