Rules Throttle

Categories

RDF

Component ID

2603990

Component name

Rules Throttle

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

The Rules Throttle module allows an administrator to insert a "throttle" delay action into a rule set. The delay can be specified by the administrator in millionths of a second, up to a theoretical maximum of 2,000 seconds*.

The action also provides three return values: 1) a microtime() timestamp from before the delay begins; 2) a microtime() timestamp from after the delay completes; and 3) a calculation of the duration of the delay. These values are available to subsequent rules actions.

Although the delay can be implemented for any number of reasons, the original idea for the module was to help an administrator buffer or throttle rules' use of resources, especially when those rules/actions depend on outside services, like API's, where usage limits may be imposed. Examples of this include API's such as 3rd party geocoders, weather providers, financial data, email services, etc, which often restrict the number of API calls your site can make during a given period of time. On high volume sites, this can cause inconsistent results when working with large data sets. This module allows you to "throttle" those API calls to help keep within those usage limits.

*The Rules Throttle module delay feature relies entirely on the PHP "usleep" function. That function accepts a single parameter (time in microseconds), which is provided as an integer. In general, PHP integers have a maximum value of about two billion, which equates to 2,000 seconds.

Aside: Although many administrators avoid enabling the core PHP Filter module, an administrator could easily add similar functionality by enabling PHP Filter, then adding a custom PHP action to a rule set, and manually coding in the PHP usleep function, eg: usleep($your_variable);.

Installation: I don't have a git repo for it yet, so I've included a ZIP file for now. It is comprised of a folder containing three files.

1) Download, unzip, and add to your sites/all/modules folder, like so:

sites/all/modules/rules_throttle/rules_throttle.info
sites/all/modules/rules_throttle/rules_throttle.module
sites/all/modules/rules_throttle/rules_throttle.rules.inc

2) Clear all caches

3) Enable the module

4) Add and configure an action in rules

If you have any trouble, search/open an issue. I'll do what I can to help.

This sandbox module was sponsored by TheGoSite.com.