@fedify/redis 2.3.0-dev.994 → 2.3.0-pr.809.37
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/codec.d.cts +1 -0
- package/dist/codec.d.ts +1 -1
- package/dist/codec.js +1 -1
- package/dist/kv.d.cts +1 -0
- package/dist/kv.d.ts +1 -1
- package/dist/kv.js +1 -1
- package/dist/mod.d.cts +1 -0
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js +1 -1
- package/dist/mq.cjs +16 -0
- package/dist/mq.d.cts +3 -1
- package/dist/mq.d.ts +3 -2
- package/dist/mq.js +16 -0
- package/package.json +7 -7
package/dist/codec.d.cts
CHANGED
package/dist/codec.d.ts
CHANGED
package/dist/codec.js
CHANGED
package/dist/kv.d.cts
CHANGED
package/dist/kv.d.ts
CHANGED
package/dist/kv.js
CHANGED
package/dist/mod.d.cts
CHANGED
package/dist/mod.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
2
|
import { Codec, CodecError, DecodingError, EncodingError, JsonCodec } from "./codec.js";
|
|
3
3
|
import { RedisKvStore, RedisKvStoreOptions } from "./kv.js";
|
|
4
4
|
import { RedisMessageQueue, RedisMessageQueueOptions } from "./mq.js";
|
package/dist/mod.js
CHANGED
package/dist/mq.cjs
CHANGED
|
@@ -121,6 +121,22 @@ var RedisMessageQueue = class {
|
|
|
121
121
|
await multi.exec();
|
|
122
122
|
if (baseTs <= now) this.#redis.publish(this.#channelKey, "");
|
|
123
123
|
}
|
|
124
|
+
async getDepth() {
|
|
125
|
+
const now = Temporal.Now.instant().epochMilliseconds;
|
|
126
|
+
const [queuedCount, readyCount] = await this.#redis.eval(`
|
|
127
|
+
return {
|
|
128
|
+
redis.call("ZCARD", KEYS[1]),
|
|
129
|
+
redis.call("ZCOUNT", KEYS[1], "-inf", ARGV[1])
|
|
130
|
+
}
|
|
131
|
+
`, 1, this.#queueKey, now);
|
|
132
|
+
const queued = Number(queuedCount);
|
|
133
|
+
const ready = Number(readyCount);
|
|
134
|
+
return {
|
|
135
|
+
queued,
|
|
136
|
+
ready,
|
|
137
|
+
delayed: Math.max(0, queued - ready)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
124
140
|
/**
|
|
125
141
|
* Returns the Redis key used to lock a specific ordering key.
|
|
126
142
|
*/
|
package/dist/mq.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
1
2
|
import { Codec } from "./codec.cjs";
|
|
2
|
-
import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
|
|
3
|
+
import { MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
|
|
3
4
|
import { Cluster, Redis, RedisKey } from "ioredis";
|
|
4
5
|
|
|
5
6
|
//#region src/mq.d.ts
|
|
@@ -79,6 +80,7 @@ declare class RedisMessageQueue implements MessageQueue, Disposable {
|
|
|
79
80
|
constructor(redis: () => Redis | Cluster, options?: RedisMessageQueueOptions);
|
|
80
81
|
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
81
82
|
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
83
|
+
getDepth(): Promise<MessageQueueDepth>;
|
|
82
84
|
listen(handler: (message: any) => void | Promise<void>, options?: MessageQueueListenOptions): Promise<void>;
|
|
83
85
|
[Symbol.dispose](): void;
|
|
84
86
|
[Symbol.asyncDispose](): Promise<void>;
|
package/dist/mq.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
2
|
import { Codec } from "./codec.js";
|
|
3
|
-
import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
|
|
3
|
+
import { MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "@fedify/fedify";
|
|
4
4
|
import { Cluster, Redis, RedisKey } from "ioredis";
|
|
5
5
|
|
|
6
6
|
//#region src/mq.d.ts
|
|
@@ -80,6 +80,7 @@ declare class RedisMessageQueue implements MessageQueue, Disposable {
|
|
|
80
80
|
constructor(redis: () => Redis | Cluster, options?: RedisMessageQueueOptions);
|
|
81
81
|
enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
82
82
|
enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
|
|
83
|
+
getDepth(): Promise<MessageQueueDepth>;
|
|
83
84
|
listen(handler: (message: any) => void | Promise<void>, options?: MessageQueueListenOptions): Promise<void>;
|
|
84
85
|
[Symbol.dispose](): void;
|
|
85
86
|
[Symbol.asyncDispose](): Promise<void>;
|
package/dist/mq.js
CHANGED
|
@@ -121,6 +121,22 @@ var RedisMessageQueue = class {
|
|
|
121
121
|
await multi.exec();
|
|
122
122
|
if (baseTs <= now) this.#redis.publish(this.#channelKey, "");
|
|
123
123
|
}
|
|
124
|
+
async getDepth() {
|
|
125
|
+
const now = Temporal.Now.instant().epochMilliseconds;
|
|
126
|
+
const [queuedCount, readyCount] = await this.#redis.eval(`
|
|
127
|
+
return {
|
|
128
|
+
redis.call("ZCARD", KEYS[1]),
|
|
129
|
+
redis.call("ZCOUNT", KEYS[1], "-inf", ARGV[1])
|
|
130
|
+
}
|
|
131
|
+
`, 1, this.#queueKey, now);
|
|
132
|
+
const queued = Number(queuedCount);
|
|
133
|
+
const ready = Number(readyCount);
|
|
134
|
+
return {
|
|
135
|
+
queued,
|
|
136
|
+
ready,
|
|
137
|
+
delayed: Math.max(0, queued - ready)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
124
140
|
/**
|
|
125
141
|
* Returns the Redis key used to lock a specific ordering key.
|
|
126
142
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/redis",
|
|
3
|
-
"version": "2.3.0-
|
|
3
|
+
"version": "2.3.0-pr.809.37+0574ba5c",
|
|
4
4
|
"description": "Redis drivers for Fedify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -78,19 +78,19 @@
|
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@js-temporal/polyfill": "^0.5.1",
|
|
81
|
-
"@logtape/logtape": "^2.0
|
|
81
|
+
"@logtape/logtape": "^2.1.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"ioredis": "^5.8.2",
|
|
85
|
-
"@fedify/fedify": "^2.3.0-
|
|
85
|
+
"@fedify/fedify": "^2.3.0-pr.809.37+0574ba5c"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@std/async": "npm:@jsr/std__async@^1.0.13",
|
|
89
89
|
"@types/node": "^22.17.0",
|
|
90
|
-
"tsdown": "^0.
|
|
91
|
-
"typescript": "^
|
|
92
|
-
"@fedify/
|
|
93
|
-
"@fedify/
|
|
90
|
+
"tsdown": "^0.22.0",
|
|
91
|
+
"typescript": "^6.0.0",
|
|
92
|
+
"@fedify/fixture": "^2.0.0",
|
|
93
|
+
"@fedify/testing": "^2.3.0-pr.809.37+0574ba5c"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build:self": "tsdown",
|