-
Notifications
You must be signed in to change notification settings - Fork 91
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
Long polling with queue.get? #15
Comments
It doesn't do long polling currently, since I don't think MongoDB does long polling - and since we're dependent on that, this would be impossible. I guess the best way to do this would be just 'poll' (rather than 'long poll') and the library could poll for you. e.g. every 5 seconds ( I'd leave I'm not promising I'm going to implement it, though I think it's a good idea. Feel free to send a PR if you're keen. :) |
I think you could implement long polling by storing the callback internally inside the mongodb-queue instance when the I haven't really looked at your code yet. I might try implementing it at some point. |
This won't work (in general) since you could be using the MongoDB queue collection from any number of services. ie. your web service might be adding messages to the queue, and a background worker might be taking them off, therefore your suggestion here won't really work. (It won't really harm it either, but it won't do what you're expecting it to.) Even if it was added like this, there should definitely be an upper limit amount of time to wait before returning |
Oh I see what you mean. I'm working on an email service and I was planning on using this queue for sending emails and retrying failed attempts. All of this happens on a server within a single Node process. So this might be a very specific use case I guess? I think this feature would be useful if you're only planning on using this queue from a single service. |
I think Anyway, feel free to close if you like. I may have a crack at |
I'm trying to use this polling function:
It's probably not perfect, but we'll see |
Hi,
Is it possible to do long polling using this library? If I understand correctly, queue.get simply passes undefined to the callback if the queue is empty right? Is there a way for it to simply not call the callback until the queue becomes non empty?
The text was updated successfully, but these errors were encountered: