Add request throttling support with a default implementation.#1
Merged
TimMikeladze merged 5 commits intoOct 6, 2025
Conversation
Owner
|
@NyaStone Thank you for the PR! Could you please rebase and resolve conflicts? I'll merge and publish right away. |
…hrottling and queue system
81b7ce1 to
b13a3f1
Compare
Contributor
Author
|
The PR has been rebased, and should be ready to be merged. |
Owner
|
Published as |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What:
Added support for fetch request throttling to simplify handling the YGOPRODeck API rate limit, including a default implementation.
Why:
Implementing throttling within the client is necessary to exclude cache hits from the throttling logic.
How:
TimeQueueinterfaceIntroduced a
TimeQueueinterface to describe a queue/throttler.The only required method is:
enqueue<T>(task: () => Promise<T>, signal: AbortSignal): Promise<T>This method should delay the task if necessary, resolve with the task result, and be abortable via the provided signal.
TimeQueue.requestmethod of YgoApi to enqueue fetch tasks and await them instead of running instantly.Default implementation:
SignalBasedQueueTL;DR of the implementation:
AbortControllerto signal when the task is ready to run. The task is then executed, and its resolution is returned.The interval is measured between fetch starts, not between one resolving and the next starting.
Added a test suite for the
SignalBasedQueueimplementation.Checklist: