jhurliman / node-rate-limiter

A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled
MIT License
1.5k stars 132 forks source link

tokenBucket now functions #2

Closed martindale closed 12 years ago

martindale commented 12 years ago

When instantiating a tokenBucket, it always appeared to create a bucket of size 1 -- I've since fixed this issue for @LocalSense's needs, but please comment if there's something I've broken.

jhurliman commented 12 years ago

The primary issue was a handful of misnamed variables. I extracted this code from an internal project to release as open source, and in the process of trying to clean it up I broke some of the variable references. Those have been fixed now and I pushed version 1.0.0 to npm, including a basic set of unit tests for TokenBucket. Thanks for tracking down the issue @martindale. I'm going to close this pull request now that the issue is resolved. If you find any other issues please let me know.

martindale commented 12 years ago

Awesome, thanks! We'll see if we can roll it in to our fork (and consequently ntwitter as well).

martindale commented 12 years ago

Hrm, I don't see version 1.0.0 on npm, but I do have 0.1.0. Was there a mistake in versioning, or has it not been pushed yet?

jhurliman commented 12 years ago
$ npm info limiter
npm http GET https://registry.npmjs.org/limiter
npm http 304 https://registry.npmjs.org/limiter

{ name: 'limiter',
  description: 'A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled',
  'dist-tags': { latest: '1.0.0' },
  versions: [ '0.0.2', '1.0.0' ],
  maintainers: 'jhurliman <jhurliman@cull.tv>',
  time: 
   { '0.0.2': '2012-04-17T00:38:05.679Z',
     '1.0.0': '2012-07-17T20:10:01.194Z' },
  author: 'John Hurliman <jhurliman@cull.tv>',
  repository: 
   { type: 'git',
     url: 'git://github.com/jhurliman/node-rate-limiter' },
  version: '1.0.0',
  dependencies: {},
  devDependencies: { assert: '0.4.9', vows: '0.6.3' },
  keywords: 
   [ 'rate',
     'limiting',
     'throttling' ],
  bugs: { url: 'http://github.com/jhurliman/node-rate-limiter/issues' },
  directories: { lib: './lib/' },
  main: './index.js',
  licenses: 
   { type: 'MIT',
     url: 'http://github.com/jhurliman/node-rate-limiter/raw/master/LICENSE.txt' },
  dist: 
   { shasum: '017dd406145e0ff058ac9b72ba2525543dda716a',
     tarball: 'http://registry.npmjs.org/limiter/-/limiter-1.0.0.tgz' } }
martindale commented 12 years ago

Aha, awesome. I was using the wrong package. Thanks!