2.5.3
Two abstract classes were imported from the Redis adapter repository:
- the
ClusterAdapter
class, which manages the messages sent between the server instances of the cluster - the
ClusterAdapterWithHeartbeat
class, which extends theClusterAdapter
and adds a heartbeat mechanism in order to check the healthiness of the other instances
Other 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.
Bug Fixes
- cluster: fix count in fetchSockets() method (80af4e9)
- cluster: notify the other nodes when closing (0e23ff0)
Performance Improvements
- cluster: use timer.refresh() (d99a71b)
Links
- Diff: 2.5.2...2.5.3