Skip to content

Add ThrottleLock#70

Merged
Tyrrrz merged 9 commits intoprimefrom
copilot/add-throttle-lock-utility
Apr 19, 2026
Merged

Add ThrottleLock#70
Tyrrrz merged 9 commits intoprimefrom
copilot/add-throttle-lock-utility

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 19, 2026

  • Switch to monotonic time source (Stopwatch.GetTimestamp() / GetElapsedTime())
  • Fix double timestamp capture (resolved by monotonic switch)
  • Consolidate timing tests into 2 focused tests
  • Use is { } last pattern for nullable long? check (superseded — field is now non-nullable)
  • Redesign WaitAsync_Test: 50ms interval, 3 sequential waits, assert >= interval * 3; initialize _lastTimestamp at construction so every call is throttled
  • Fix CSharpier formatting issue that was causing CI build failure

Copilot AI and others added 2 commits April 19, 2026 09:56
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/5b1b4463-062d-4baa-9f51-9c3e039da2ce

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 19, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 19, 2026 09:59
Copilot AI review requested due to automatic review settings April 19, 2026 09:59
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.93%. Comparing base (45628b8) to head (29359f5).
⚠️ Report is 2 commits behind head on prime.

Additional details and impacted files
@@            Coverage Diff             @@
##            prime      #70      +/-   ##
==========================================
+ Coverage   93.85%   93.93%   +0.07%     
==========================================
  Files         128      130       +2     
  Lines        2524     2557      +33     
  Branches      200      202       +2     
==========================================
+ Hits         2369     2402      +33     
  Misses        112      112              
  Partials       43       43              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports ThrottleLock from YoutubeDownloader into PowerKit as an internal utility to enforce a minimum interval between consecutive async acquisitions (rate-limiting).

Changes:

  • Added ThrottleLock (SemaphoreSlim-backed) with WaitAsync(CancellationToken) to throttle acquisitions to a fixed cadence.
  • Added unit tests covering first call behavior, subsequent throttling, post-interval behavior, cancellation, and disposal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
PowerKit/ThrottleLock.cs Introduces the ThrottleLock utility and its async throttling logic behind TFM guards.
PowerKit.Tests/ThrottleLockTests.cs Adds timing-based unit tests validating ThrottleLock.WaitAsync behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit/ThrottleLock.cs Outdated
Comment thread PowerKit/ThrottleLock.cs Outdated
Comment thread PowerKit/ThrottleLock.cs Outdated
Comment thread PowerKit.Tests/ThrottleLockTests.cs Outdated
Comment thread PowerKit.Tests/ThrottleLockTests.cs Outdated
Comment thread PowerKit.Tests/ThrottleLockTests.cs
Comment thread PowerKit/ThrottleLock.cs Outdated
Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/6c2e73ca-9252-429e-bebe-6c015e217d6e

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Comment thread PowerKit.Tests/ThrottleLockTests.cs
…estamp at construction

Agent-Logs-Url: https://github.com/Tyrrrz/PowerKit/sessions/47ec4d3c-0e4b-4866-9cea-e0293c3d8fba

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 19, 2026

@copilot please fix formatting

Copilot AI requested a review from Tyrrrz April 19, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants