Name : perl-Schedule-RateLimiter
| |
Version : 0.01
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp155.7.1
| Date : 2023-07-20 16:56:53
|
Group : Development/Libraries/Perl
| Source RPM : perl-Schedule-RateLimiter-0.01-lp155.7.1.src.rpm
|
Size : 0.01 MB
| |
Packager : https://www_suse_com/
| |
Summary : prevent events from happening too quickly.
|
Description :
This module provides a way to voluntarily restrict how many times a given action may take place within a specified time frame. Such a tool may be useful if you have written something which periodically polls some public resource and want to ensure that you do not overburden that resource with too many requests.
Initially, one might think that solving this problem would be as simple as sleeping for the number of seconds divided by the number of iterations in between each event. However, that would only be correct if the event took no time at all.
If you know exactly how much time each event is going to take then you could build an even more complicated one-liner such as this:
sleep( (seconds / iterations) - single_event_time )
This module is intended to address the other cases when the exact run-time of each event is unknown and variable. This module will try very hard to allow an event to happen as many times as possible without exceeding the specified bounds.
For example, suppose you want to write something that checks an \'incoming\' directory once a minute for files and then does something with those files if it finds any. If it takes you two seconds to process those files, then you want to wait 58 seconds before polling the directory again. If it takes 30 seconds to process those files, then you only want to wait 30 seconds. And if it takes 3 minutes, then you want to poll the directory again immediately as soon as you are done.
my $throttle = Schedule::RateLimiter->new ( seconds => 60 ); &poll_and_process while ( $throttle->event );
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-S/15.5/noarch |