-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rate limit write function further
- Loading branch information
Showing
10 changed files
with
121 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Default exponential backoff configuration for retries. | ||
*/ | ||
const RETRY_CONF = {retries: 3, factor: 2, minTimeout: 1000}; | ||
|
||
/** | ||
* Rate limit per API endpoints. | ||
* | ||
* See {@link https://developer.github.com/v3/search/#rate-limit|Search API rate limit}. | ||
* See {@link https://developer.github.com/v3/#rate-limiting|Rate limiting}. | ||
*/ | ||
const RATE_LIMITS = { | ||
search: ((60 * 1000) / 30) * 1.1, // 30 calls per minutes => 1 call every 2s + 10% safety margin | ||
core: { | ||
read: ((60 * 60 * 1000) / 5000) * 1.1, // 5000 calls per hour => 1 call per 720ms + 10% safety margin | ||
write: 3000, // 1 call every 3 seconds | ||
}, | ||
}; | ||
|
||
/** | ||
* Global rate limit to prevent abuse. | ||
* | ||
* See {@link https://developer.github.com/v3/guides/best-practices-for-integrators/#dealing-with-abuse-rate-limits|Dealing with abuse rate limits} | ||
*/ | ||
const GLOBAL_RATE_LIMIT = 1000; | ||
|
||
module.exports = {RETRY_CONF, RATE_LIMITS, GLOBAL_RATE_LIMIT}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const RETRY_CONF = {retries: 3, factor: 1, minTimeout: 1, maxTimeout: 1}; | ||
|
||
const RATE_LIMITS = {search: 1, core: {read: 1, write: 1}}; | ||
|
||
const GLOBAL_RATE_LIMIT = 1; | ||
|
||
export default {RETRY_CONF, RATE_LIMITS, GLOBAL_RATE_LIMIT}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.