@fedify/redis 2.0.0-dev.236 → 2.0.0-dev.241
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/dist/mq.cjs +20 -28
- package/dist/mq.js +20 -28
- package/package.json +9 -8
package/dist/mq.cjs
CHANGED
|
@@ -115,31 +115,29 @@ var RedisMessageQueue = class {
|
|
|
115
115
|
await handler(message);
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
subRedis.off("message", poll);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
118
|
+
await this.#subRedis.subscribe(this.#channelKey);
|
|
119
|
+
/**
|
|
120
|
+
* Cast to Redis for event methods. Both Redis and Cluster extend EventEmitter
|
|
121
|
+
* and get the same methods via applyMixin at runtime, but their TypeScript
|
|
122
|
+
* interfaces are incompatible:
|
|
123
|
+
* - Redis declares specific overloads: on(event: "message", cb: (channel, message) => void)
|
|
124
|
+
* - Cluster only has generic: on(event: string | symbol, listener: Function)
|
|
125
|
+
*
|
|
126
|
+
* This makes the union type Redis | Cluster incompatible for these method calls.
|
|
127
|
+
* The cast is safe because both classes use applyMixin(Class, EventEmitter) which
|
|
128
|
+
* copies all EventEmitter prototype methods, giving them identical pub/sub functionality.
|
|
129
|
+
*
|
|
130
|
+
* @see https://github.com/redis/ioredis/blob/main/lib/Redis.ts#L863 (has specific overloads)
|
|
131
|
+
* @see https://github.com/redis/ioredis/blob/main/lib/cluster/index.ts#L1110 (empty interface)
|
|
132
|
+
*/
|
|
133
|
+
const subRedis = this.#subRedis;
|
|
134
|
+
subRedis.on("message", poll);
|
|
135
|
+
const timeouts = /* @__PURE__ */ new Set();
|
|
139
136
|
signal?.addEventListener("abort", () => {
|
|
137
|
+
subRedis.off("message", poll);
|
|
140
138
|
for (const timeout of timeouts) clearTimeout(timeout);
|
|
141
139
|
});
|
|
142
|
-
|
|
140
|
+
await poll();
|
|
143
141
|
while (!signal?.aborted) {
|
|
144
142
|
let timeout;
|
|
145
143
|
await new Promise((resolve) => {
|
|
@@ -153,12 +151,6 @@ var RedisMessageQueue = class {
|
|
|
153
151
|
if (timeout != null) timeouts.delete(timeout);
|
|
154
152
|
await poll();
|
|
155
153
|
}
|
|
156
|
-
return await new Promise((resolve) => {
|
|
157
|
-
signal?.addEventListener("abort", () => {
|
|
158
|
-
promise.catch(() => resolve()).then(() => resolve());
|
|
159
|
-
});
|
|
160
|
-
promise.catch(() => resolve()).then(() => resolve());
|
|
161
|
-
});
|
|
162
154
|
}
|
|
163
155
|
[Symbol.dispose]() {
|
|
164
156
|
clearInterval(this.#loopHandle);
|
package/dist/mq.js
CHANGED
|
@@ -114,31 +114,29 @@ var RedisMessageQueue = class {
|
|
|
114
114
|
await handler(message);
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
subRedis.off("message", poll);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
117
|
+
await this.#subRedis.subscribe(this.#channelKey);
|
|
118
|
+
/**
|
|
119
|
+
* Cast to Redis for event methods. Both Redis and Cluster extend EventEmitter
|
|
120
|
+
* and get the same methods via applyMixin at runtime, but their TypeScript
|
|
121
|
+
* interfaces are incompatible:
|
|
122
|
+
* - Redis declares specific overloads: on(event: "message", cb: (channel, message) => void)
|
|
123
|
+
* - Cluster only has generic: on(event: string | symbol, listener: Function)
|
|
124
|
+
*
|
|
125
|
+
* This makes the union type Redis | Cluster incompatible for these method calls.
|
|
126
|
+
* The cast is safe because both classes use applyMixin(Class, EventEmitter) which
|
|
127
|
+
* copies all EventEmitter prototype methods, giving them identical pub/sub functionality.
|
|
128
|
+
*
|
|
129
|
+
* @see https://github.com/redis/ioredis/blob/main/lib/Redis.ts#L863 (has specific overloads)
|
|
130
|
+
* @see https://github.com/redis/ioredis/blob/main/lib/cluster/index.ts#L1110 (empty interface)
|
|
131
|
+
*/
|
|
132
|
+
const subRedis = this.#subRedis;
|
|
133
|
+
subRedis.on("message", poll);
|
|
134
|
+
const timeouts = /* @__PURE__ */ new Set();
|
|
138
135
|
signal?.addEventListener("abort", () => {
|
|
136
|
+
subRedis.off("message", poll);
|
|
139
137
|
for (const timeout of timeouts) clearTimeout(timeout);
|
|
140
138
|
});
|
|
141
|
-
|
|
139
|
+
await poll();
|
|
142
140
|
while (!signal?.aborted) {
|
|
143
141
|
let timeout;
|
|
144
142
|
await new Promise((resolve) => {
|
|
@@ -152,12 +150,6 @@ var RedisMessageQueue = class {
|
|
|
152
150
|
if (timeout != null) timeouts.delete(timeout);
|
|
153
151
|
await poll();
|
|
154
152
|
}
|
|
155
|
-
return await new Promise((resolve) => {
|
|
156
|
-
signal?.addEventListener("abort", () => {
|
|
157
|
-
promise.catch(() => resolve()).then(() => resolve());
|
|
158
|
-
});
|
|
159
|
-
promise.catch(() => resolve()).then(() => resolve());
|
|
160
|
-
});
|
|
161
153
|
}
|
|
162
154
|
[Symbol.dispose]() {
|
|
163
155
|
clearInterval(this.#loopHandle);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/redis",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.241+58c8126c",
|
|
4
4
|
"description": "Redis drivers for Fedify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -82,20 +82,21 @@
|
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"ioredis": "^5.8.2",
|
|
85
|
-
"@fedify/fedify": "^2.0.0-dev.
|
|
85
|
+
"@fedify/fedify": "^2.0.0-dev.241+58c8126c"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@std/async": "npm:@jsr/std__async@^1.0.13",
|
|
89
89
|
"@types/node": "^22.17.0",
|
|
90
90
|
"tsdown": "^0.12.9",
|
|
91
91
|
"typescript": "^5.9.3",
|
|
92
|
-
"@fedify/
|
|
93
|
-
"@fedify/
|
|
92
|
+
"@fedify/fixture": "^2.0.0",
|
|
93
|
+
"@fedify/testing": "^2.0.0-dev.241+58c8126c"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
|
-
"build": "tsdown",
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"test
|
|
96
|
+
"build:self": "tsdown",
|
|
97
|
+
"build": "pnpm --filter @fedify/redis... run build:self",
|
|
98
|
+
"prepublish": "pnpm build",
|
|
99
|
+
"test": "pnpm build && node --experimental-transform-types --test",
|
|
100
|
+
"test:bun": "pnpm build && bun test --timeout=10000"
|
|
100
101
|
}
|
|
101
102
|
}
|