new: queue package for Solid 2.0#918
Conversation
🦋 Changeset detectedLatest commit: 89406a1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/queue-initial.md:
- Line 11: The changeset incorrectly documents makePriorityQueue with the old
constructor signature; update the changeset text to reflect the actual API used
in the PR by changing the documented form from makePriorityQueue<T>(comparator,
initialValues?) to the modifier form makePriorityQueue(q, comparator) (or the
exact PR contract signature), and ensure the description mentions it modifies an
existing queue rather than returning a non-reactive standalone queue; reference
makePriorityQueue and the queue modifier form in your edit so release notes
match the implemented API.
In `@packages/queue/CHANGELOG.md`:
- Around line 8-10: Update the CHANGELOG entries to reflect the actual exported
signatures: change the createQueue line to document
createQueue<T>(initialValues?) — reactive FIFO queue backed by Solid signals;
exposes queue, first, last, size, isEmpty, add, remove, clear (include the
`queue` accessor), update makePriorityQueue to describe the modifier form
makePriorityQueue<T>(q, comparator) (not a factory), and keep
createPriorityQueue<T>(comparator, initialValues?) as-is; adjust wording so the
listed symbols (`createQueue`, `makePriorityQueue`, `createPriorityQueue`) match
their real function signatures and exposed members.
In `@packages/queue/README.md`:
- Around line 55-63: The README type definitions for Queue and ReactiveQueue are
missing the public push method; update the type shapes (the Queue<T> and
ReactiveQueue<T> entries) to include a push signature that matches the runtime
(e.g., push: (...items: T[]) => void), keeping it consistent with the existing
add method and other members (first, last, size, isEmpty, add, remove, clear).
Ensure both occurrences of the type doc (the block around Queue<T> and the
similar block later referenced) are updated so the documented contract matches
the runtime API.
- Around line 121-125: The README demonstrates makePriorityQueue with the wrong
argument order; the implementation expects an existing queue first and the
comparator second. Update all examples and descriptive text that show
makePriorityQueue to pass the initial values/queue as the first argument and the
comparator function as the second (fix both example blocks that currently show
the reversed signature), and adjust any prose that describes the function
signature to reflect (q, comparator) instead of (comparator, initialValues).
In `@packages/queue/src/task-queue.ts`:
- Around line 149-157: The function createConcurrentTaskQueue accepts invalid
concurrency values (0, negative, NaN, non-integers) which can leave pending
tasks unresolved; fix by validating and normalizing the concurrency parameter at
the start of createConcurrentTaskQueue (before runNext/pending are used): ensure
concurrency is a finite integer >= 1 (e.g., Number.isFinite and Number.isInteger
checks) and throw a clear RangeError if not, so runNext and enqueue() can rely
on a valid positive concurrency value; reference createConcurrentTaskQueue,
runNext, and pending when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 41062067-ef1c-4638-8855-330fba9554ba
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (13)
.changeset/queue-initial.mdpackages/queue/CHANGELOG.mdpackages/queue/LICENSEpackages/queue/README.mdpackages/queue/dev/index.tsxpackages/queue/package.jsonpackages/queue/src/index.tspackages/queue/src/priority-queue.tspackages/queue/src/queue.tspackages/queue/src/task-queue.tspackages/queue/test/index.test.tspackages/queue/test/server.test.tspackages/queue/tsconfig.json
Adds a new
@solid-primitives/queuepackage with six primitives covering plain FIFO queues, priority queues, and async task queues — all built for Solid 2.0 (beta.14).Primitives
makeQueue<T>/createQueue<T>— FIFO queue in non-reactive and reactive forms.createQueueexposesqueue,first,last,size,isEmptyas reactive accessors. Both supportadd(append to back) andpush(comparator, ...items)(sorted insert) so priority behavior can be applied without a separate type.makePriorityQueue(q, comparator)— modifier that turns any queue (reactive or plain) into a priority queue by bindingcomparatortoadd. Designed to compose withmakeQueue/createQueuerather than duplicate their logic.createPriorityQueue<T>(comparator, initialValues?)— ergonomic reactive factory: pre-sorts initial values and delegates tomakePriorityQueue(createQueue(...), comparator).createTaskQueue<T>()— runs async tasks one at a time in FIFO order.enqueue(task)returns aPromise<T>. Exposes reactivesize(pending count) andactive(boolean). Uses a plainasyncdrain loop rather than Solid'saction()sosize/activeupdate live during execution.createConcurrentTaskQueue<T>(concurrency)— likecreateTaskQueuebut runs up toconcurrencytasks in parallel.activeisAccessor<number>(count of running tasks).Implementation notes
INTERNAL_OPTIONS(ownedWrite: true) so the queues work outside a reactive owner.action()was considered and rejected for the drain loop — Solid 2.0's transition system holds all scheduler writes globally while a transition is open, making livesize/activestate unobservable mid-execution.queue.ts,priority-queue.ts,task-queue.ts, barrelindex.ts.Summary by CodeRabbit
New Features
@solid-primitives/queuepackage with FIFO and priority queue primitivesDocumentation