File: README

package info (click to toggle)
libschedule-ratelimiter-perl 0.01-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 88 kB
  • sloc: perl: 47; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 1,784 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Schedule::RateLimiter version 0.01
==========================

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.

  # Don't let this event happen more than 5 times in a 60 second period.
  my $throttle = Schedule::RateLimiter->new ( iterations => 5,
                                      seconds    => 60 );

  # Cycle forever, but not too fast.
  while ( $throttle->event() ) {
      &do_something;
  }

INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

  Test::More
  Time::HiRest

TODO

* Add a constructor parameter that takes number of seconds and iterations and
normalizes so the number of iterations equals one.  This defeats the best fit
model and gives you the most even fit instead.

* Add a way to find out how much time it will take before the next event may
run.

* Add support for multiple requirements (for example, 5 in 100 seconds AND 6 in
120 seconds).

* Add support for a best-fit situation where there are multiple events
with different restrictions happening together.

* Add support to "roll back" an event that was recorded but did not happen.

* Add support to alter the limits on an object that already has recorded
events.


COPYRIGHT AND LICENCE

This module was authored by Daniel J. Wright (wright@pair.com) for pair
Networks, Inc.

Copyright (C) 2003 pair Networks, Inc.   (www.pair.com)

This module is licensed under the same license at Perl itself.