Fix background worker to run only onces. While loop should be user ha… - #24
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #24 +/- ##
=======================================
Coverage 77.95% 77.95%
=======================================
Files 2 2
Lines 186 186
Branches 28 28
=======================================
Hits 145 145
Misses 21 21
Partials 20 20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR implements a significant behavioral change to continuous background workers, changing them from running in an infinite loop to executing exactly once. The responsibility for implementing loops is now explicitly shifted to the user.
Changes:
- Removed automatic
whileloop from continuous worker code generation, making workers execute only once - Removed iteration tracking since continuous workers no longer iterate automatically
- Updated all tests to expect single execution behavior instead of multiple iterations
- Added new documentation file (CLAUDE.md) explaining the architecture and the explicit pattern for continuous workers
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/MinimalWorker.Generators/WorkerEmitter.cs | Removed the automatic while (!token.IsCancellationRequested) loop from continuous worker generation, removed iteration tracking, and simplified telemetry/logging to reflect single-execution behavior |
| test/MinimalWorker.Test/TelemetryTests.cs | Updated all telemetry tests to expect single execution, removed iteration assertions, and added signal mechanism to gauge test to measure worker while running |
| test/MinimalWorker.Test/ServiceResolutionTests.cs | Updated all service resolution tests to expect exactly one execution instead of multiple iterations |
| test/MinimalWorker.Test/ScopingTests.cs | Updated scoping tests to verify continuous workers use a single scope for their single execution |
| test/MinimalWorker.Test/MultiFileWorkerTests.cs | Updated multi-file worker tests to expect single execution per worker |
| test/MinimalWorker.Test/ErrorHandlerTests.cs | Simplified error handling tests to expect single execution and single exception instead of multiple iterations |
| test/MinimalWorker.Test/ContinuousWorkerTests.cs | Added new test explicitly verifying single execution, updated all existing tests to expect once-only behavior, and removed delays that were previously needed for multiple iterations |
| test/MinimalWorker.Test/BuilderPatternTests.cs | Removed unnecessary delay from test since worker now executes only once |
| CLAUDE.md | New documentation file explaining architecture, worker behavior, testing patterns, and explicitly stating that continuous workers run exactly once and users must implement their own loops |
…ndled