The Socket.IO in-memory adapter
MIT License
Bot releases are hidden (Show)
Published by darrachequesne 8 months ago
Two abstract classes were imported from the Redis adapter repository:
ClusterAdapter
class, which manages the messages sent between the server instances of the clusterClusterAdapterWithHeartbeat
class, which extends the ClusterAdapter
and adds a heartbeat mechanism in order to check the healthiness of the other instancesOther adapters can then just extend those classes and only have to implement the pub/sub mechanism (and not the internal chit-chat protocol):
class MyAdapter extends ClusterAdapterWithHeartbeat {
constructor(nsp, pubSub, opts) {
super(nsp, opts);
this.pubSub = pubSub;
pubSub.subscribe("main-channel", (message) => this.onMessage(message));
pubSub.subscribe("specific-channel#" + this.uid, (response) => this.onResponse(response));
}
doPublish(message) {
return this.pubSub.publish("main-channel", message);
}
doPublishResponse(requesterUid, response) {
return this.pubSub.publish("specific-channel#" + requesterUid, response);
}
}
Besides, the number of "timeout reached: only x responses received out of y" errors (which can happen when a server instance leaves the cluster) should be greatly reduced by this commit.
Published by darrachequesne over 2 years ago
Published by darrachequesne about 3 years ago
Published by darrachequesne over 3 years ago
Published by darrachequesne almost 4 years ago
Published by darrachequesne almost 4 years ago
Published by darrachequesne about 4 years ago
Published by darrachequesne about 4 years ago
The dist/ directory was not up-to-date when publishing the previous version...