Skip Menu |

This queue is for tickets about the Data-Throttler CPAN distribution.

Report information
The Basics
Id: 33407
Status: open
Priority: 0/
Queue: Data-Throttler

People
Owner: Nobody in particular
Requestors: FERRENCY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Feature request: min_items parameter
Hello, I would like to request support for a "min_items" parameter to Data::Throttler. This would allow the use of Data::Throttler to be used in what I would describe as "threshold mode," as well as the current "throttle" mode. Basically: If min_items is defined, try_push will return false unless there are at least min_items events counted in the buckets. However, the try_push() call will still increment the current bucket's count, even if the min_items threshold was not reached yet. (This would implicitly make max_items optional if min_items was specified.) I would be using this for rate limiting of events other than data output. The way I would use this would be to create restrictions such as, "an event X won't happen unless it has happened at least 3 times in an hour." For example: if an error condition occurs too many times, send an e-mail notification to someone about it. It is almost adequate to test !$throttler->try_push() instead of modifying Data::Throttler. However, the reason this will not work is because once $throttler->try_push starts returning false, the events are no longer counted. In this case, even if the event happens many times, and the Throttler should remain above the threshold limit, the events aren't recorded, so the buckets empty out and try_push() starts returning true (so the event threshold is no longer reached). You may consider this feature request to be outside the scope of what you intended to do with Data::Throttler. However, your module is already very useful for generic event rate limiting outside the realm of data transit, and supporting min_items would make it even more useful in this regard. Thanks! Alan Ferrency
On Mon Feb 18 17:35:34 2008, FERRENCY wrote: Show quoted text
> It is almost adequate to test !$throttler->try_push() instead of > modifying Data::Throttler. However, the reason this will not work is > because once $throttler->try_push starts returning false, the events are > no longer counted.
Sorry about the long delay on this request, just stumbled across it by accident. I think we can add the feature by allowing an option $throttler->try_push( force => 1 ); to the method that keeps increasing the counter regardless whether the threshold has been reached or not. By checking the return value and negating it, you should get the desired indication whether the alarm should be triggered. What do you think?