feat: integrate RequestShaper with dispatcher#119
Open
TheArchitectit wants to merge 7 commits intomcowger:mainfrom
Open
feat: integrate RequestShaper with dispatcher#119TheArchitectit wants to merge 7 commits intomcowger:mainfrom
TheArchitectit wants to merge 7 commits intomcowger:mainfrom
Conversation
- Add type definitions: ShaperKey, QueueWaiter, QueueResult - Add QueueFullError exception class - Add ShaperTarget and ShaperTargetStatus interfaces - Add ShaperStatus summary interface - Add RequestShaper singleton class with getInstance() Part 1 of 4: Types and Core Infrastructure for low-RPM request shaping
- Add initialize() method for service startup - Add reload() method for config hot-reload - Add stop() method for graceful shutdown - Add cleanupExpiredRequests() for queue maintenance Part 2 of 4: Lifecycle Management for low-RPM request shaping
- Add getStatus() and getAllStatus() for runtime monitoring - Add isShaped() to check if provider/model is rate-limited - Add canDispatchNow() to check budget availability - Add consumeBudget() for permit acquisition - Add getRemainingBudget() and getWaitTimeMs() - Add refillBudgetIfNeeded() with token bucket algorithm - Add getShapedCount() for summary statistics Part 3 of 4: Status and Budget APIs for low-RPM request shaping
- Add acquirePermit() for dispatcher integration with queueing - Add releasePermit() to return budget after request completion - Add getQueueDepth() and getQueueWaiters() for monitoring Part 4 of 5: Queue Operations for low-RPM request shaping
- Add admitNextIfAvailable() for queue admission - Add clearQueue() for graceful shutdown/reload - Add start/stopCleanupTimer() for queue maintenance - Add initializeTarget() with persistence hydration - Add loadBudgetFromPersistence() and persistToPersistence() - Add discoverShapedTargets() for config parsing - Add resolveLookupKey(), toStatus(), makeKey() helpers - Add resetInstance() for testing Part 5 of 5: Private Implementation for low-RPM request shaping Completes the RequestShaper service implementation.
- Add RequestShaper and QueueFullError imports - Add acquireShaperPermit() for queue-based rate limiting - Add releaseShaperPermit() to return permits after requests - Integrate permit acquisition/release in dispatch flows - Handle queue timeouts and queue full errors
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Contributor
Author
Code OverviewThis PR integrates RequestShaper with the dispatcher. Key Changes:
Methods Added:
Integration Points:
Flow:Error Handling:
|
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.
Part 5: Dispatcher Integration (119 lines)
Integrate RequestShaper with dispatcher service.
Size: 119 lines ✅