SocketCluster / SocketCluster/socketcluster
Global Redis Subscriber
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6.2k
- Forks
- 318
- PR merge metrics
- No merged PRs in 30d
Description
I use node_redis to subscribe to a channel which then publishes to all the subscribed clients
The below code is inside worker.js & SC runs 4 worker process.
var RedSubclient = redis.createClient(6379, '127.0.0.1');
RedSubclient.psubscribe(subChannelName);
RedSubclient.on("pmessage", function(pattern, channel, message){
scServer.exchange.publish(channel, message);
});
The issue is that, this code receives & publishes each message 4 times.
Looks like the Redisclient should be used globally, but I don't have clear idea how to do it.
Can anyone share a snippet?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Redis subscriber code in worker.js and trace how it is launched across the four worker processes. Reproduce a publish with multiple workers and determine the intended subscription behavior; done means each message is published to subscribed clients once rather than once per worker.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, redis
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100