|
1 | 1 | # History
|
2 | 2 |
|
| 3 | +- [2.5.3](#253-2024-02-21) (Feb 2024) |
3 | 4 | - [2.5.2](#252-2023-01-12) (Jan 2023)
|
4 | 5 | - [2.5.1](#251-2023-01-06) (Jan 2023)
|
5 | 6 | - [2.5.0](#250-2023-01-06) (Jan 2023)
|
|
19 | 20 |
|
20 | 21 | # Release notes
|
21 | 22 |
|
| 23 | +## [2.5.3](https://github.com/socketio/socket.io-adapter/compare/2.5.2...2.5.3) (2024-02-21) |
| 24 | + |
| 25 | +Two abstract classes were imported from the [Redis adapter repository](https://github.com/socketio/socket.io-redis-adapter/blob/bd32763043a2eb79a21dffd8820f20e598348adf/lib/cluster-adapter.ts): |
| 26 | + |
| 27 | +- the `ClusterAdapter` class, which manages the messages sent between the server instances of the cluster |
| 28 | +- the `ClusterAdapterWithHeartbeat` class, which extends the `ClusterAdapter` and adds a heartbeat mechanism in order to check the healthiness of the other instances |
| 29 | + |
| 30 | +Other adapters can then just extend those classes and only have to implement the pub/sub mechanism (and not the internal chit-chat protocol): |
| 31 | + |
| 32 | +```js |
| 33 | +class MyAdapter extends ClusterAdapterWithHeartbeat { |
| 34 | + constructor(nsp, pubSub, opts) { |
| 35 | + super(nsp, opts); |
| 36 | + this.pubSub = pubSub; |
| 37 | + pubSub.subscribe("main-channel", (message) => this.onMessage(message)); |
| 38 | + pubSub.subscribe("specific-channel#" + this.uid, (response) => this.onResponse(response)); |
| 39 | + } |
| 40 | + |
| 41 | + doPublish(message) { |
| 42 | + return this.pubSub.publish("main-channel", message); |
| 43 | + } |
| 44 | + |
| 45 | + doPublishResponse(requesterUid, response) { |
| 46 | + return this.pubSub.publish("specific-channel#" + requesterUid, response); |
| 47 | + } |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +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](https://github.com/socketio/socket.io-adapter/commit/0e23ff0cc671e3186510f7cfb8a4c1147457296f). |
| 52 | + |
| 53 | + |
| 54 | +### Bug Fixes |
| 55 | + |
| 56 | +* **cluster:** fix count in fetchSockets() method ([80af4e9](https://github.com/socketio/socket.io-adapter/commit/80af4e939c9caf89b0234ba1e676a3887c8d0ce6)) |
| 57 | +* **cluster:** notify the other nodes when closing ([0e23ff0](https://github.com/socketio/socket.io-adapter/commit/0e23ff0cc671e3186510f7cfb8a4c1147457296f)) |
| 58 | + |
| 59 | + |
| 60 | +### Performance Improvements |
| 61 | + |
| 62 | +* **cluster:** use timer.refresh() ([d99a71b](https://github.com/socketio/socket.io-adapter/commit/d99a71b5588f53f0b181eee989ab2ac939f965db)) |
| 63 | + |
| 64 | + |
| 65 | + |
22 | 66 | ## [2.5.2](https://github.com/socketio/socket.io-adapter/compare/2.5.1...2.5.2) (2023-01-12)
|
23 | 67 |
|
24 | 68 | The `ws` dependency was moved from `peerDependencies` to `dependencies`, in order to prevent issues like [this](https://github.com/socketio/socket.io-redis-adapter/issues/478).
|
|
0 commit comments