-
Notifications
You must be signed in to change notification settings - Fork 869
add support for ioredis #652
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
Conversation
|
Deals with #642 |
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.
Is this backward compatible? node_redis officially hasn't documented the callback on the .subscribe method.
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.
|
You should be setting |
|
Doesn't this take care of |
|
Sure, but I'd prefer mentioning support for ioredis for Redis Cluster users and provide a basic sample injecting ioredis in :) |
|
got it, adding the documentation. |
|
How long are you using kue with ioredis? is your PR tested widely for all kue features? |
|
I haven't used ioredis with kue and no it is not widely tested. I could create job, process them and add a complete event callback. But when I pass ioredis cluster client its not working. I changed the redis client in the specs to use ioredis client and all the tests pass ( they do throw Connection closed error for few of them). |
then we should not yet merge this in until this is resolved. |
|
yeah, need to make sure everything works. btw, the reason cluster is not working is because it throws [Error: All keys in the pipeline should belong to the same slot(expect "q:jobs:inactive" belongs to slot 11113).]One way to fix it is to do this ( using Redis Cluster hash tags) client.prefix = '{' +options.prefix + '}'; |
|
Updated Readme.md with ioredis cluster docs. I have found similar results with default |
Can you elaborate on the problem and tell how is it fixed that way? |
|
From redis cluster specs: Redis Cluster implements a concept called hash tags that can be used in order to force certain keys to be stored in the same node. so for {q}:jobs and {q}:ids only the part inside the curly braces ( here |
|
the critical part should be lua scripting, I migrated |
|
hadn't enough time to test this @az7arul yet, Aren't you testing with ioredis ? |
|
I already test it. Test passed without any error but it's not working... i'll try to dig down the problem maybe in this weekend. |
|
+1 It would be awesome if kue worked with ioredis |
|
From reading this change it can only deployed on an empty queue? Might be an idea to make the prefix changing optional. |
I didn't get your point. This patch is changing |
|
this should mean that you can scale via using different Kue namespaces, but not within a single Kue namespace. Right @az7arul ? |
|
My point is: If there's stuff in |
|
Why this should happen? |
|
Ahaaa, got you just now... Pordon @leepa |
|
In a production environment - this kind of thing really matters. It'd surely be wise to allow for seamless migration in a production environment...? |
|
and ofcourse we should think a work around for single redis deployments where you can stick with Only be warned that I'm not yet testing/accepting this PR since I've done no tests on it. Testers are welcome :) |
|
I've been testing this PR with ioredis in sentinel mode for a couple of days now, and so far, had no issues at all. I obviously had to do a flushall on Redis beforehand. Will be moving the code out of dev and into our test environment in the next few days, where it should get a good workout. Also, one small gotcha I found is that because ioredis only emits an error event if it has a listener on it, I couldn't work out why I was getting uncaught exceptions during redis failover, but it turns out that Kue attaches to the ioredis error event by default, so that Kue error event needs to be caught and handled in the case of a redis-server going down and ioredis attempting reconnection to a slave. I've attached directly to the ioredis events and can now get some good logging out of it, in the case of lost connections, failovers, new connections, ready etc. I'll keep testing and let you know if I find any issues. Cheers. |
|
@dandanknight great hearing this from you... Can you please give us more feedback and also create a PR for any improvements you are on? |
|
Quick update, I'm successfully using ioredis in our test environment, which consists of two web servers, each running 4 express threads (load balanced by PM2), which pop jobs (via Kue) onto a master/slave Redis store (watched by redis-sentinels), then two worker servers, each with two consumer threads (also PM2 balanced) consuming the jobs. I've had no issues to report so far. I have been shutting down redis-servers, sentinels, restarting etc, and ioredis does a great job of picking back up the connections when the services become available. It also has an offline queue which allows it to still take in jobs and cache them until a server becomes available again. I've written an ioredis wrapper that both my producer and consumer apps use, which you require, create an instance of, and it basically just returns a new ioredis object, but along the way also subscribes to all the extra events that ioredis offers. I can share my code if anyone wants it, which uses ioredis's retry connection strategies etc, but I'm quite new to nodejs, so there are probably much better ways to do it than I have done! |
|
Valuable comment @dandanknight , Are you using this PR for ioredis integration with Kue? |
|
Hi @behrad , yes using this PR. Not had to make any changes to it. Published it to a local private repo (Sinopia) so can be installed across our servers using npm for now, untill you guys merge it. My connection module looks like.... And then simply connect the normal way using.... Like I said, I'm quiet new to Node, so please don't take any of this code as gospel! Also, I've straight copied and pasted from my IDE, so there may be a few specific bits in there that are only relevant to my project. Cheers. |
No description provided.