-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support getting current Promise queue length #39
Support getting current Promise queue length #39
Conversation
Useful in cases e.g. a consuming program wants to check for promise-queue congestion, for reporting on task backlogs.
index.js
Outdated
@@ -92,6 +92,8 @@ export default function pThrottle({limit, interval, strict}) { | |||
|
|||
throttled.isEnabled = true; | |||
|
|||
throttled.queueLength = () => queue.size; |
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 should be a getter instead of a function.
queueSize
would be a more corrct name.
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.
Sorry - I might be misunderstanding the comment - I don't believe we can use the get
keyword here 'cos we're not in a class / object literal, we're in a function.
Would you mind providing a snippet of what you'd like this changing to and I can get it sorted? Cheers!
(Renamed to queueSize
though!)
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.
Object.defineProperty
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.
Should be sorted in latest commit!
Thanks :) |
Would it make more sense if queueSize was a property of the throttle not the throttled function? |
Useful in cases e.g. a consuming program wants to check for promise-queue congestion, for reporting on growing backlogs (e.g. In my case exposing the current promise-queue length as a custom Prometheus metric to alert if the process is seeing latency in churning through what should be a quick-to-process set of queued promises.)