-
Notifications
You must be signed in to change notification settings - Fork 446
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
fix: replace p-queue with less restrictive queue #2339
Conversation
Adds a `Queue` class to `@libp2p/utils` modelled on p-queue with a few key differences: 1. The queue is externally accessible so we can modify it before jobs run 2. It can be turned into an async generator 3. Jobs remain in the queue while they are executing for better introspection 4. It integrates with libp2p metrics, if desired The dial queue has been replaced with this new queue class, this means we don't need to maintain a separate internal queue for pending dials since the dial queue itself is accessible.
Remove extra/add missing deps shown by ipfs/aegir#1426 Depends on #2339
packages/utils/src/queue/index.ts
Outdated
await this.onEvent('idle') | ||
} | ||
|
||
private async onEvent (event: keyof QueueEvents<JobReturnType>, filter?: () => boolean): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be abortable?
I guess not if clear/abort will allow all pending promises (from public methods, onEmpty, onSizeLessThan, onIdle, toGenerator) to resolve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not abortable in p-queue, though it makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are abortable now
"./queue": { | ||
"types": "./dist/src/queue/index.d.ts", | ||
"import": "./dist/src/queue/index.js" | ||
}, | ||
"./peer-queue": { | ||
"types": "./dist/src/peer-queue.d.ts", | ||
"import": "./dist/src/peer-queue.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achingbrain This PR introduces BREAKING CHANGE and actually broke many libp2p projects. Why not to bump major version if you break package API? Libp2p packages use caret ranges and automatically will try to update this package when installed.
Adds a
Queue
class to@libp2p/utils
modelled on p-queue with a few key differences:The dial queue has been replaced with this new queue class, this means we don't need to maintain a separate internal queue for pending dials since the dial queue itself is accessible.
Change checklist