@fedify/redis 2.2.0-dev.613 → 2.2.0-dev.628
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.cjs +4 -8
- package/dist/codec.js +2 -6
- package/dist/kv.cjs +6 -11
- package/dist/kv.js +3 -8
- package/dist/mod.cjs +6 -8
- package/dist/mod.js +2 -5
- package/dist/mq.cjs +8 -16
- package/dist/mq.js +5 -12
- package/package.json +5 -5
- package/dist/_virtual/rolldown_runtime.cjs +0 -33
package/dist/codec.cjs
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
5
|
-
const node_buffer = require_rolldown_runtime.__toESM(require("node:buffer"));
|
|
6
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let node_buffer = require("node:buffer");
|
|
7
4
|
//#region src/codec.ts
|
|
8
5
|
/**
|
|
9
6
|
* An error that occurs when encoding or decoding data.
|
|
@@ -58,9 +55,8 @@ var JsonCodec = class {
|
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
};
|
|
61
|
-
|
|
62
58
|
//#endregion
|
|
63
59
|
exports.CodecError = CodecError;
|
|
64
60
|
exports.DecodingError = DecodingError;
|
|
65
61
|
exports.EncodingError = EncodingError;
|
|
66
|
-
exports.JsonCodec = JsonCodec;
|
|
62
|
+
exports.JsonCodec = JsonCodec;
|
package/dist/codec.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { Buffer } from "node:buffer";
|
|
5
|
-
|
|
6
3
|
//#region src/codec.ts
|
|
7
4
|
/**
|
|
8
5
|
* An error that occurs when encoding or decoding data.
|
|
@@ -57,6 +54,5 @@ var JsonCodec = class {
|
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
};
|
|
60
|
-
|
|
61
57
|
//#endregion
|
|
62
|
-
export { CodecError, DecodingError, EncodingError, JsonCodec };
|
|
58
|
+
export { CodecError, DecodingError, EncodingError, JsonCodec };
|
package/dist/kv.cjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const require_codec = require('./codec.cjs');
|
|
6
|
-
const node_buffer = require_rolldown_runtime.__toESM(require("node:buffer"));
|
|
7
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_codec = require("./codec.cjs");
|
|
4
|
+
let node_buffer = require("node:buffer");
|
|
8
5
|
//#region src/kv.ts
|
|
9
6
|
/**
|
|
10
7
|
* A key–value store that uses Redis as the underlying storage.
|
|
@@ -73,8 +70,7 @@ var RedisKvStore = class {
|
|
|
73
70
|
await this.#redis.del(serializedKey);
|
|
74
71
|
}
|
|
75
72
|
#deserializeKey(redisKey) {
|
|
76
|
-
|
|
77
|
-
return suffix.split("::").map((p) => p.replaceAll("_:", ":"));
|
|
73
|
+
return redisKey.slice(this.#keyPrefixStr.length).split("::").map((p) => p.replaceAll("_:", ":"));
|
|
78
74
|
}
|
|
79
75
|
/**
|
|
80
76
|
* {@inheritDoc KvStore.list}
|
|
@@ -112,6 +108,5 @@ var RedisKvStore = class {
|
|
|
112
108
|
} while (cursor !== "0");
|
|
113
109
|
}
|
|
114
110
|
};
|
|
115
|
-
|
|
116
111
|
//#endregion
|
|
117
|
-
exports.RedisKvStore = RedisKvStore;
|
|
112
|
+
exports.RedisKvStore = RedisKvStore;
|
package/dist/kv.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { JsonCodec } from "./codec.js";
|
|
5
3
|
import { Buffer } from "node:buffer";
|
|
6
|
-
|
|
7
4
|
//#region src/kv.ts
|
|
8
5
|
/**
|
|
9
6
|
* A key–value store that uses Redis as the underlying storage.
|
|
@@ -72,8 +69,7 @@ var RedisKvStore = class {
|
|
|
72
69
|
await this.#redis.del(serializedKey);
|
|
73
70
|
}
|
|
74
71
|
#deserializeKey(redisKey) {
|
|
75
|
-
|
|
76
|
-
return suffix.split("::").map((p) => p.replaceAll("_:", ":"));
|
|
72
|
+
return redisKey.slice(this.#keyPrefixStr.length).split("::").map((p) => p.replaceAll("_:", ":"));
|
|
77
73
|
}
|
|
78
74
|
/**
|
|
79
75
|
* {@inheritDoc KvStore.list}
|
|
@@ -111,6 +107,5 @@ var RedisKvStore = class {
|
|
|
111
107
|
} while (cursor !== "0");
|
|
112
108
|
}
|
|
113
109
|
};
|
|
114
|
-
|
|
115
110
|
//#endregion
|
|
116
|
-
export { RedisKvStore };
|
|
111
|
+
export { RedisKvStore };
|
package/dist/mod.cjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require_mq = require('./mq.cjs');
|
|
7
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_codec = require("./codec.cjs");
|
|
4
|
+
const require_kv = require("./kv.cjs");
|
|
5
|
+
const require_mq = require("./mq.cjs");
|
|
8
6
|
exports.CodecError = require_codec.CodecError;
|
|
9
7
|
exports.DecodingError = require_codec.DecodingError;
|
|
10
8
|
exports.EncodingError = require_codec.EncodingError;
|
|
11
9
|
exports.JsonCodec = require_codec.JsonCodec;
|
|
12
10
|
exports.RedisKvStore = require_kv.RedisKvStore;
|
|
13
|
-
exports.RedisMessageQueue = require_mq.RedisMessageQueue;
|
|
11
|
+
exports.RedisMessageQueue = require_mq.RedisMessageQueue;
|
package/dist/mod.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { CodecError, DecodingError, EncodingError, JsonCodec } from "./codec.js";
|
|
5
3
|
import { RedisKvStore } from "./kv.js";
|
|
6
4
|
import { RedisMessageQueue } from "./mq.js";
|
|
7
|
-
|
|
8
|
-
export { CodecError, DecodingError, EncodingError, JsonCodec, RedisKvStore, RedisMessageQueue };
|
|
5
|
+
export { CodecError, DecodingError, EncodingError, JsonCodec, RedisKvStore, RedisMessageQueue };
|
package/dist/mq.cjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
5
|
-
const require_codec = require('./codec.cjs');
|
|
6
|
-
const __logtape_logtape = require_rolldown_runtime.__toESM(require("@logtape/logtape"));
|
|
7
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_codec = require("./codec.cjs");
|
|
8
4
|
//#region src/mq.ts
|
|
9
|
-
const logger = (0,
|
|
5
|
+
const logger = (0, require("@logtape/logtape").getLogger)([
|
|
10
6
|
"fedify",
|
|
11
7
|
"redis",
|
|
12
8
|
"mq"
|
|
@@ -114,8 +110,7 @@ var RedisMessageQueue = class {
|
|
|
114
110
|
}
|
|
115
111
|
async #poll() {
|
|
116
112
|
logger.debug("Polling for messages...");
|
|
117
|
-
|
|
118
|
-
if (result == null) {
|
|
113
|
+
if (await this.#redis.set(this.#lockKey, this.#workerId, "EX", Math.floor(this.#pollIntervalMs / 1e3 * 2), "NX") == null) {
|
|
119
114
|
logger.debug("Another worker is already processing messages; skipping...");
|
|
120
115
|
return;
|
|
121
116
|
}
|
|
@@ -129,11 +124,9 @@ var RedisMessageQueue = class {
|
|
|
129
124
|
const orderingKey = decoded[2];
|
|
130
125
|
if (orderingKey != null) {
|
|
131
126
|
const orderingLockKey = this.#getOrderingLockKey(orderingKey);
|
|
132
|
-
|
|
133
|
-
if (lockResult == null) continue;
|
|
127
|
+
if (await this.#redis.set(orderingLockKey, this.#workerId, "EX", 60, "NX") == null) continue;
|
|
134
128
|
}
|
|
135
|
-
|
|
136
|
-
if (removed === 0) {
|
|
129
|
+
if (await this.#redis.zrem(this.#queueKey, encodedMessage) === 0) {
|
|
137
130
|
if (orderingKey != null) await this.#redis.del(this.#getOrderingLockKey(orderingKey));
|
|
138
131
|
continue;
|
|
139
132
|
}
|
|
@@ -211,6 +204,5 @@ var RedisMessageQueue = class {
|
|
|
211
204
|
this.#subRedis.disconnect();
|
|
212
205
|
}
|
|
213
206
|
};
|
|
214
|
-
|
|
215
207
|
//#endregion
|
|
216
|
-
exports.RedisMessageQueue = RedisMessageQueue;
|
|
208
|
+
exports.RedisMessageQueue = RedisMessageQueue;
|
package/dist/mq.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
4
2
|
import { JsonCodec } from "./codec.js";
|
|
5
3
|
import { getLogger } from "@logtape/logtape";
|
|
6
|
-
|
|
7
4
|
//#region src/mq.ts
|
|
8
5
|
const logger = getLogger([
|
|
9
6
|
"fedify",
|
|
@@ -113,8 +110,7 @@ var RedisMessageQueue = class {
|
|
|
113
110
|
}
|
|
114
111
|
async #poll() {
|
|
115
112
|
logger.debug("Polling for messages...");
|
|
116
|
-
|
|
117
|
-
if (result == null) {
|
|
113
|
+
if (await this.#redis.set(this.#lockKey, this.#workerId, "EX", Math.floor(this.#pollIntervalMs / 1e3 * 2), "NX") == null) {
|
|
118
114
|
logger.debug("Another worker is already processing messages; skipping...");
|
|
119
115
|
return;
|
|
120
116
|
}
|
|
@@ -128,11 +124,9 @@ var RedisMessageQueue = class {
|
|
|
128
124
|
const orderingKey = decoded[2];
|
|
129
125
|
if (orderingKey != null) {
|
|
130
126
|
const orderingLockKey = this.#getOrderingLockKey(orderingKey);
|
|
131
|
-
|
|
132
|
-
if (lockResult == null) continue;
|
|
127
|
+
if (await this.#redis.set(orderingLockKey, this.#workerId, "EX", 60, "NX") == null) continue;
|
|
133
128
|
}
|
|
134
|
-
|
|
135
|
-
if (removed === 0) {
|
|
129
|
+
if (await this.#redis.zrem(this.#queueKey, encodedMessage) === 0) {
|
|
136
130
|
if (orderingKey != null) await this.#redis.del(this.#getOrderingLockKey(orderingKey));
|
|
137
131
|
continue;
|
|
138
132
|
}
|
|
@@ -210,6 +204,5 @@ var RedisMessageQueue = class {
|
|
|
210
204
|
this.#subRedis.disconnect();
|
|
211
205
|
}
|
|
212
206
|
};
|
|
213
|
-
|
|
214
207
|
//#endregion
|
|
215
|
-
export { RedisMessageQueue };
|
|
208
|
+
export { RedisMessageQueue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/redis",
|
|
3
|
-
"version": "2.2.0-dev.
|
|
3
|
+
"version": "2.2.0-dev.628+7f7a1e9b",
|
|
4
4
|
"description": "Redis drivers for Fedify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -82,14 +82,14 @@
|
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"ioredis": "^5.8.2",
|
|
85
|
-
"@fedify/fedify": "^2.2.0-dev.
|
|
85
|
+
"@fedify/fedify": "^2.2.0-dev.628+7f7a1e9b"
|
|
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": "^5.9.
|
|
92
|
-
"@fedify/testing": "^2.2.0-dev.
|
|
90
|
+
"tsdown": "^0.21.6",
|
|
91
|
+
"typescript": "^5.9.2",
|
|
92
|
+
"@fedify/testing": "^2.2.0-dev.628+7f7a1e9b",
|
|
93
93
|
"@fedify/fixture": "^2.0.0"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { Temporal } = require("@js-temporal/polyfill");
|
|
3
|
-
|
|
4
|
-
//#region rolldown:runtime
|
|
5
|
-
var __create = Object.create;
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
-
key = keys[i];
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(exports, '__toESM', {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return __toESM;
|
|
32
|
-
}
|
|
33
|
-
});
|