@socket.io/redis-streams-adapter 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -20
- package/dist/util.d.ts +0 -1
- package/dist/util.js +13 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,28 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
The `@socket.io/redis-streams-adapter` package allows broadcasting packets between multiple Socket.IO servers.
|
|
4
4
|
|
|
5
|
-
Supported features:
|
|
6
|
-
|
|
7
|
-
- [broadcasting](https://socket.io/docs/v4/broadcasting-events/)
|
|
8
|
-
- [utility methods](https://socket.io/docs/v4/server-instance/#Utility-methods)
|
|
9
|
-
- [`socketsJoin`](https://socket.io/docs/v4/server-instance/#socketsJoin)
|
|
10
|
-
- [`socketsLeave`](https://socket.io/docs/v4/server-instance/#socketsLeave)
|
|
11
|
-
- [`disconnectSockets`](https://socket.io/docs/v4/server-instance/#disconnectSockets)
|
|
12
|
-
- [`fetchSockets`](https://socket.io/docs/v4/server-instance/#fetchSockets)
|
|
13
|
-
- [`serverSideEmit`](https://socket.io/docs/v4/server-instance/#serverSideEmit)
|
|
14
|
-
- [connection state recovery](https://socket.io/docs/v4/connection-state-recovery)
|
|
15
|
-
|
|
16
|
-
Related packages:
|
|
17
|
-
|
|
18
|
-
- Redis adapter: https://github.com/socketio/socket.io-redis-adapter/
|
|
19
|
-
- Redis emitter: https://github.com/socketio/socket.io-redis-emitter/
|
|
20
|
-
- MongoDB adapter: https://github.com/socketio/socket.io-mongo-adapter/
|
|
21
|
-
- MongoDB emitter: https://github.com/socketio/socket.io-mongo-emitter/
|
|
22
|
-
- Postgres adapter: https://github.com/socketio/socket.io-postgres-adapter/
|
|
23
|
-
- Postgres emitter: https://github.com/socketio/socket.io-postgres-emitter/
|
|
24
|
-
|
|
25
5
|
**Table of contents**
|
|
26
6
|
|
|
7
|
+
- [Supported features](#supported-features)
|
|
27
8
|
- [Installation](#installation)
|
|
28
9
|
- [Usage](#usage)
|
|
29
10
|
- [With the `redis` package](#with-the-redis-package)
|
|
@@ -34,6 +15,15 @@ Related packages:
|
|
|
34
15
|
- [How it works](#how-it-works)
|
|
35
16
|
- [License](#license)
|
|
36
17
|
|
|
18
|
+
## Supported features
|
|
19
|
+
|
|
20
|
+
| Feature | `socket.io` version | Support |
|
|
21
|
+
|---------------------------------|---------------------|------------------------------------------------|
|
|
22
|
+
| Socket management | `4.0.0` | :white_check_mark: YES (since version `0.1.0`) |
|
|
23
|
+
| Inter-server communication | `4.1.0` | :white_check_mark: YES (since version `0.1.0`) |
|
|
24
|
+
| Broadcast with acknowledgements | `4.5.0` | :white_check_mark: YES (since version `0.1.0`) |
|
|
25
|
+
| Connection state recovery | `4.6.0` | :white_check_mark: YES (since version `0.1.0`) |
|
|
26
|
+
|
|
37
27
|
## Installation
|
|
38
28
|
|
|
39
29
|
```
|
package/dist/util.d.ts
CHANGED
package/dist/util.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GETDEL = exports.SET = exports.XRANGE = exports.XADD = exports.XREAD = exports.
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
|
-
const redis_1 = require("redis");
|
|
3
|
+
exports.GETDEL = exports.SET = exports.XRANGE = exports.XADD = exports.XREAD = exports.hasBinary = void 0;
|
|
6
4
|
function hasBinary(obj, toJSON) {
|
|
7
5
|
if (!obj || typeof obj !== "object") {
|
|
8
6
|
return false;
|
|
@@ -29,10 +27,6 @@ function hasBinary(obj, toJSON) {
|
|
|
29
27
|
return false;
|
|
30
28
|
}
|
|
31
29
|
exports.hasBinary = hasBinary;
|
|
32
|
-
function randomId() {
|
|
33
|
-
return (0, crypto_1.randomBytes)(8).toString("hex");
|
|
34
|
-
}
|
|
35
|
-
exports.randomId = randomId;
|
|
36
30
|
/**
|
|
37
31
|
* Whether the client comes from the `redis` package
|
|
38
32
|
*
|
|
@@ -64,16 +58,18 @@ function mapResult(result) {
|
|
|
64
58
|
*/
|
|
65
59
|
function XREAD(redisClient, streamName, offset, readCount) {
|
|
66
60
|
if (isRedisV4Client(redisClient)) {
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
61
|
+
return Promise.resolve().then(() => require("redis")).then((redisPackage) => {
|
|
62
|
+
return redisClient.xRead(redisPackage.commandOptions({
|
|
63
|
+
isolated: true,
|
|
64
|
+
}), [
|
|
65
|
+
{
|
|
66
|
+
key: streamName,
|
|
67
|
+
id: offset,
|
|
68
|
+
},
|
|
69
|
+
], {
|
|
70
|
+
COUNT: readCount,
|
|
71
|
+
BLOCK: 5000,
|
|
72
|
+
});
|
|
77
73
|
});
|
|
78
74
|
}
|
|
79
75
|
else {
|
package/package.json
CHANGED