-
-
Notifications
You must be signed in to change notification settings - Fork 31
Align Queue and TxQueue APIs with unified completion semantics #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
📊 JSDoc Documentation Analysis📈 Current Analysis ResultsThis comment is automatically updated on each push. View the analysis script for details. |
Bundle Size Analysis
|
9659391 to
e3d3c90
Compare
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.
Summary
Comprehensive refactoring to align Queue and TxQueue APIs with consistent completion semantics using
Cause.Doneas the unified completion primitive. This eliminates API inconsistencies and provides a cleaner, more predictable interface for both Queue implementations.Changes Overview
Phase 0: Unified Completion API (5 commits)
Cause.Donesingleton for completion signaling across Effect libraryCause.DoneQueueDonewithCause.DoneNoSuchElementErrortoCause.DoneQueue.interrupt()for graceful queue closureEffect<boolean>indicating if interruption succeededTxQueue.clear()to returnArray<A>instead ofvoidPhase 1: Interface Structure (1 commit)
Enqueueinterface for interface segregation principleEnqueue,Dequeue,QueuePhase 2: Return Type Fixes (2 commits)
TxQueue.takeAll()to returnNonEmptyArray<A>TxQueue.offerAll()to returnArray<A>instead ofChunk<A>Phase 3: Missing Operations (2 commits)
Queue.poll()for non-blocking takeEffect<Option<A>>Queue.peek()to view items without removingEffect<A>with same error channel astake()Phase 4: API Refinements (5 commits)
Queue.end()to usefailCause(causeFail(Done))Queue.failCauseUnsafe()and madefailCausedualdone()/doneUnsafe()entirelyfailCause/failCauseUnsafefailCauseas primary completion primitiveQueue.Donereferences toCause.DoneAPI Impact
Breaking Changes
Queue.done(exit)→ removed, useQueue.failCause(Cause.fail(Done))orQueue.end()Queue.doneUnsafe(exit)→ removed, useQueue.failCauseUnsafe(Cause.fail(Done))orQueue.endUnsafe()Queue.Done→ useCause.DoneinsteadQueue.isDone()→ useCause.isDone()insteadTxQueue.clear()→ now returnsArray<A>instead ofvoidTxQueue.takeAll()→ now returnsNonEmptyArray<A>instead ofArray<A>TxQueue.offerAll()→ now returnsArray<A>instead ofChunk<A>New APIs
Queue.interrupt()- graceful queue closure with drainingQueue.poll()- non-blocking take operationQueue.peek()- view items without removingQueue.Enqueue<A, E>- write-only interfaceQueue.failCauseUnsafe(cause)- synchronous cause-based failureCause.Done- unified completion type for queues/streamsImplementation Details
Key Design Decisions
Cause.Doneas completion primitive - Unified approach across Queue, TxQueue, Stream, ChannelfailCauseoverdone(exit)- Simpler mental model, one way to signal completion/errorsFiles Changed (20 files)
Testing
✅ All 106 test files passing (3,241 tests)
✅ All docgen checks passing (2,667 examples validated)
✅ All linting checks passing
✅ Type checking passing
Test Coverage
Migration Guide
Before
After
Benefits
Cause.Donetype across Queue, TxQueue, Stream, Channeldone(exit)in favor offailCauseCause.Donelives alongside other Effect error typesRelated Issues
Addresses API inconsistencies between Queue and TxQueue implementations that have been present since their creation.