Add concurrent request limiter and implement it in GitHub integration #1603
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed ✍️
What
🤖 Generated by Copilot at 83de21a
This pull request adds a concurrent request limiter feature for the GitHub GraphQL queries used by the integrations service. The feature uses a
RedisCache
to store and update the number of concurrent requests for each integration and prevents exceeding the GitHub API rate limit. The feature is implemented in therateLimiter.ts
file and thecaching.ts
file, and is used by theBaseQuery
class and its subclasses in thegraphql
folder. The feature is also applied to theprocessStream.ts
andprocessWebhookStream.ts
files, which handle the GitHub integration streams.
🤖 Generated by Copilot at 83de21a
Why
How
🤖 Generated by Copilot at 83de21a
IConcurrentRequestLimiter
and a new typeLimiter
in thecaching.ts
file to define the concurrent request limiter logic and its parameters (link,link)IConcurrentRequestLimiter
interface in theConcurrentRequestLimiter
class in therateLimiter.ts
file, which uses a cache to store and update the current number of concurrent requests for each integration, and atimeout
function to implement a delay mechanism (link,link)decrement
method in theICache
interface and theRedisCache
class to support the concurrent request limiter logic (link,link)limiter
of typeLimiter
to thegetSinglePage
method of theBaseQuery
class in thebaseQuery.ts
file, and add a conditional logic to use theprocessWithLimit
method of thelimiter.concurrentRequestLimiter
to execute the GraphQL query with the concurrent request limit (link,link,link)getConcurrentRequestLimiter
to theprocessStream.ts
file, which creates a singleton concurrent request limiter for each GitHub integration using thectx.cache
and thegithub-concurrent-request-limiter
key (link,link)getSinglePage
method calls of the various GitHub GraphQL query classes in theprocessStream.ts
andprocessWebhookStream.ts
files, which handle the processing of different types of GitHub streams (link,link,link,link,link,link,link,link,link,link,link,link,link,link,link)Checklist ✅
Feature
,Improvement
, orBug
.