You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, @philschatz. This library is awesome! Thanks for keeping it up to date all this time. 🙏
Here's how I'm currently doing rate limiting:
constRateLimiter=require('limiter').RateLimiterconstlimiter=newRateLimiter(5000,'hour')constOctokat=require('octokat')constocto=newOctokat({token: process.env.GITHUB_ACCESS_TOKEN})repos.forEach(repo=>{limiter.removeTokens(1,function(){octo(repo.owner.login,repo.name).contributors.fetch().then(contributors=>// do stuff )})})
This is working okay, but I wonder if there's a better way. Thoughts?
Also, I saw this in the README:
Listeners for rate limit changes
What exactly does that mean?
The text was updated successfully, but these errors were encountered:
Unfortunately, octokat does not perform throttling but it does provide the following which may be useful:
eTag caching and you can provide your own cache handler to save to disk
an "unofficial" listener that tells you the rate limit remaining and when the limit resets
To use the listener you can doing something like the following:
constOctokat=require('./dist/node/octokat')constocto=newOctokat({emitter: function(eventType,details,response,rateLimit){const{method, path, data, options}=detailsconst{isBase64, isRaw, isBoolean, contentType}=options// The following are in seconds since epoch, not millisecondsconst{remaining, limit, reset}=rateLimitconsole.log(arguments)}})octo.repos('philschatz/octokat.js').fetch()// alternative:octo.fromUrl('/repos/philschatz/octokat.js').fetch()
It really should be on the octokat object but I was not sure if:
people would find it useful
how much detail should be sent
whether Rate limits should be left as seconds since epoch or converted to Date objects
... but now that there are 2 requests for it, I'll add it 😄
Hi, @philschatz. This library is awesome! Thanks for keeping it up to date all this time. 🙏
Here's how I'm currently doing rate limiting:
This is working okay, but I wonder if there's a better way. Thoughts?
Also, I saw this in the README:
What exactly does that mean?
The text was updated successfully, but these errors were encountered: