socket.io-redis-emitter
socket.io-redis-emitter copied to clipboard
Apply async redis features
node-redis presented new major version 4.x.x. One of the most highlighted changes is Promise support. At the current moment redis-emitter works fine with node-redis v4 :rocket:. But there can be some obstacles. For instance, if you work with AWS Lambda you have to connect to redis, do some stuff, disconnect from redis. If this.redisClient.publish()
call isn't completed yet then you will receive an error.
const client = await redis.connect();
const emitter = new Emitter(client);
emitter.emit('event', data);
await client.disconnect();
// Lambda run fails
This pr fixes it. @darrachequesne please take a look at the commit. Probably it should be merged
Hi! I think you should call quit()
instead of disconnect()
:
Before quitting, the client executes any remaining commands in its queue, and will receive replies from Redis for each of them
From: https://github.com/redis/node-redis#quitquit
Hi! I think you should call
quit()
instead ofdisconnect()
:Before quitting, the client executes any remaining commands in its queue, and will receive replies from Redis for each of them
What if you want to keep the connection alive?
As suggested from GCP Cloud Function docs, you shouldn't call quit()
or disconnect()
I'm not sure from your comment if you're supporting this change or not.
@amitozalvo hi! What I meant is that I thought the use case suggested by @vazaio was already covered in the current version, but I might be wrong. Could you please explain your use case?
Please reopen if needed.