All Projects → dandv → Rate Limit

dandv / Rate Limit

Meteor package to rate-limit a function by queuing up calls (instead of dropping them like throttle or debounce)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Rate Limit

Dtube
📺 d.tube app. A full-featured video sharing website, decentralized.
Stars: ✭ 569 (+3693.33%)
Mutual labels:  meteor
Nlg Eval
Evaluation code for various unsupervised automated metrics for Natural Language Generation.
Stars: ✭ 822 (+5380%)
Mutual labels:  meteor
Meteor Google Charts
Simple package for Google Charts on Meteor
Stars: ✭ 9 (-40%)
Mutual labels:  meteor
Meteor Astronomy
Model layer for Meteor
Stars: ✭ 608 (+3953.33%)
Mutual labels:  meteor
Base
A starting point for Meteor apps.
Stars: ✭ 654 (+4260%)
Mutual labels:  meteor
Meteor Roles
Authorization package for Meteor, compatible with built-in accounts packages
Stars: ✭ 916 (+6006.67%)
Mutual labels:  meteor
Meteor User Status
Track user connection state and inactivity in Meteor.
Stars: ✭ 555 (+3600%)
Mutual labels:  meteor
Redis Ratelimit
A fixed window rate limiter based on Redis
Stars: ✭ 15 (+0%)
Mutual labels:  rate-limiting
Demeteorizer
Converts a Meteor app into a standard Node.js application.
Stars: ✭ 717 (+4680%)
Mutual labels:  meteor
Ostrio Analytics
📊 Visitor's analytics tracking code for ostr.io service
Stars: ✭ 9 (-40%)
Mutual labels:  meteor
Gubernator
High Performance Rate Limiting MicroService and Library
Stars: ✭ 609 (+3960%)
Mutual labels:  rate-limiting
Meteor Collection Hooks
Meteor Collection Hooks
Stars: ✭ 641 (+4173.33%)
Mutual labels:  meteor
Meteor Boilerplate
A lightweight boilerplate for meteor projects
Stars: ✭ 841 (+5506.67%)
Mutual labels:  meteor
Db
GroundDB is a thin layer providing Meteor offline database and methods
Stars: ✭ 569 (+3693.33%)
Mutual labels:  meteor
Retrotanks
RetroTanks: Atari Combat Reimagined, built in Meteor.js. Great isomorphic JavaScript example.
Stars: ✭ 9 (-40%)
Mutual labels:  meteor
Pup
The Ultimate Boilerplate for Products.
Stars: ✭ 563 (+3653.33%)
Mutual labels:  meteor
Vue Meteor
🌠 Vue first-class integration in Meteor
Stars: ✭ 893 (+5853.33%)
Mutual labels:  meteor
Kickstart Meteor Polymer
⚡️ Kickstart a Meteor - Polymer project with MWC packages. (Flow Router is used to route)
Stars: ✭ 15 (+0%)
Mutual labels:  meteor
Sapporo
Web App for hosting coding competition
Stars: ✭ 10 (-33.33%)
Mutual labels:  meteor
Mongol Meteor Explore Minimongo Devtools
In-App MongoDB Editor for Meteor (Meteor DevTools)
Stars: ✭ 846 (+5540%)
Mutual labels:  meteor

rateLimit

Easily rate-limit a function to run no more often than every X miliseconds, by queuing up calls. All calls will be eventually executed, unlike throttling or debouncing, which drop extra calls.

This is useful for API clients, web crawling, or other tasks that need to wait at least some amount of time between calls, but for which throttling per se (dropping calls) is unacceptable.

On the server, you can use futures to allow returning a value from the rate-limited function. On the client, this is not yet implemented, but possible.

A private queue is used internally, as suggested on StackOverflow.

Installation

$ meteor add rate-limit

Example:

Simply run var fooLimited = rateLimit(foo, delayInMilliseconds);.

function foo(param1, param2) {
  console.log(param1, (param2 || ''));
}

var bar = rateLimit(foo, 1000);  // wait at least 1000 milliseconds between calls
foo('Starting up');
bar(1);  // runs right away
bar(2);  // runs after 1 second
bar(3, 'optional parameter');  // parameters are passed along to the original function

Usage

rateLimit(function, delayInMilliseconds, context /* default this */, options)

Parameters

  • function to call
  • minimum delayInMilliseconds to wait before consecutive calls to function
  • context to pass (defaults to this)
  • options:
    • debug: boolean - default false. Logs to the console the number of items in the queue after each call to function
    • futures: boolean - default false. MUST be enabled if you need the return value of function. Will yield execution of next statement (not block) until function returns.

TODO

See also

  • jobCollection - powerful native Meteor package for job queue processing
  • limiter - A generic rate limiter for Node.js

Author, license and copyright

Author: Dan Dascalescu (@dandv)

Development initially sponsored by StockBase, LLC.

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].