@voltro/kv 0.87.0 → 0.88.0
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/CHANGELOG.md +169 -6
- package/THIRD-PARTY-NOTICES.md +2 -1345
- package/dist/Kv.js +1 -2
- package/dist/KvStore.js +1 -2
- package/dist/analytics.js +1 -2
- package/dist/backendMemory.js +1 -2
- package/dist/backendRedis.js +1 -2
- package/dist/cacheAtomicProtocol.js +34 -24
- package/dist/cacheAtomicScript.js +19 -2
- package/dist/cacheAtomicState.js +1 -2
- package/dist/connection.js +74 -70
- package/dist/connectionAnalyticsConfig.js +1 -2
- package/dist/connectionConfigError.js +10 -0
- package/dist/connectionConfigProvider.js +1 -2
- package/dist/connectionDefinitions.js +1 -2
- package/dist/connectionMemory.js +1 -2
- package/dist/connectionMetrics.js +1 -2
- package/dist/connectionNamespace.js +1 -2
- package/dist/connectionNats.js +44 -44
- package/dist/connectionNatsConfig.js +1 -2
- package/dist/connectionNatsSubjects.js +1 -2
- package/dist/connectionOwner.js +1 -2
- package/dist/connectionPool.js +252 -252
- package/dist/connectionPrefix.js +1 -2
- package/dist/connectionScripts.js +1 -2
- package/dist/connectionSqlConfig.js +1 -2
- package/dist/connectionStorageConfig.js +1 -2
- package/dist/connectionStorageFacade.js +1 -2
- package/dist/connectionSubscriber.js +47 -47
- package/dist/driverModule.js +9 -0
- package/dist/errors.js +1 -2
- package/dist/expirySweep.js +1 -2
- package/dist/hot-contract.js +1 -2
- package/dist/hot-testing.d.ts +14 -1
- package/dist/hotMemory.js +1 -2
- package/dist/hotOperations.js +1 -2
- package/dist/hotRateLimit.js +1 -2
- package/dist/hotReadAvailability.js +1 -2
- package/dist/hotRedis.js +1 -2
- package/dist/hotRedisScript.js +1 -2
- package/dist/hotRouting.js +2 -3
- package/dist/hotState.js +1 -2
- package/dist/hotStoreConformance.js +76 -78
- package/dist/nativeRedisReads.js +2 -3
- package/dist/nativeRedisTopology.js +64 -63
- package/dist/redisDiagnostics.js +1 -2
- package/dist/redisReadPolicy.js +1 -2
- package/dist/storage.js +1 -2
- package/dist/storageAddress.js +1 -2
- package/package.json +13 -10
package/dist/connectionNats.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { KvError as e } from "./errors.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { missingDriver as t } from "./driverModule.js";
|
|
3
|
+
import { assertNatsSubject as n } from "./connectionNatsSubjects.js";
|
|
4
|
+
import { Effect as r } from "effect";
|
|
5
|
+
// src/connectionNats.ts
|
|
6
|
+
var i = new TextEncoder(), a = new TextDecoder(), o = 5e3, s = 1e3, c = async (e, t) => {
|
|
6
7
|
let n;
|
|
7
8
|
try {
|
|
8
9
|
return await Promise.race([e, new Promise((e, r) => {
|
|
@@ -13,9 +14,9 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
|
|
|
13
14
|
} finally {
|
|
14
15
|
n !== void 0 && clearTimeout(n);
|
|
15
16
|
}
|
|
16
|
-
},
|
|
17
|
-
let
|
|
18
|
-
for (let t of
|
|
17
|
+
}, l = (e) => {
|
|
18
|
+
let t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), d = !0, f = !1, p, m = (e) => {
|
|
19
|
+
for (let t of r) try {
|
|
19
20
|
t(e);
|
|
20
21
|
} catch {}
|
|
21
22
|
}, h = () => {
|
|
@@ -40,29 +41,29 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
|
|
|
40
41
|
t !== void 0 && (t.released = !0, u.delete(e), t.subscription.unsubscribe(), await t.done);
|
|
41
42
|
};
|
|
42
43
|
return {
|
|
43
|
-
publish: async (
|
|
44
|
-
t
|
|
44
|
+
publish: async (t, r) => {
|
|
45
|
+
n(t), v(), e.publish(t, i.encode(r));
|
|
45
46
|
},
|
|
46
47
|
flush: async () => {
|
|
47
|
-
v(), await
|
|
48
|
+
v(), await c(e.flush(), o);
|
|
48
49
|
},
|
|
49
50
|
subscribe: async (r) => {
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
if (
|
|
53
|
-
let
|
|
54
|
-
subscription:
|
|
51
|
+
n(r), v();
|
|
52
|
+
let i = u.get(r);
|
|
53
|
+
if (i !== void 0) return i.ready;
|
|
54
|
+
let s = e.subscribe(r), d = {
|
|
55
|
+
subscription: s,
|
|
55
56
|
released: !1,
|
|
56
57
|
done: Promise.resolve(),
|
|
57
58
|
ready: Promise.resolve()
|
|
58
59
|
};
|
|
59
60
|
u.set(r, d), d.done = (async () => {
|
|
60
61
|
try {
|
|
61
|
-
for await (let e of
|
|
62
|
+
for await (let e of s) {
|
|
62
63
|
if (f || d.released) continue;
|
|
63
|
-
let
|
|
64
|
-
for (let e of
|
|
65
|
-
e(r,
|
|
64
|
+
let n = a.decode(e.data);
|
|
65
|
+
for (let e of t) try {
|
|
66
|
+
e(r, n);
|
|
66
67
|
} catch {}
|
|
67
68
|
}
|
|
68
69
|
} finally {
|
|
@@ -72,7 +73,7 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
|
|
|
72
73
|
d.released || h();
|
|
73
74
|
}), l.add(d.done), d.done.then(() => {
|
|
74
75
|
l.delete(d.done);
|
|
75
|
-
}), d.ready =
|
|
76
|
+
}), d.ready = c(e.flush(), o).then(() => {
|
|
76
77
|
if (v(), d.released) throw Error("NATS subscription is closed");
|
|
77
78
|
}).catch(async (e) => {
|
|
78
79
|
throw u.get(r) === d && await y(r), e;
|
|
@@ -81,18 +82,18 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
|
|
|
81
82
|
unsubscribe: y,
|
|
82
83
|
onMessage: (e) => {
|
|
83
84
|
if (f) throw Error("NATS transport is closed");
|
|
84
|
-
return
|
|
85
|
-
|
|
85
|
+
return t.add(e), () => {
|
|
86
|
+
t.delete(e);
|
|
86
87
|
};
|
|
87
88
|
},
|
|
88
89
|
onTransportEvent: (e) => {
|
|
89
90
|
if (f) throw Error("NATS transport is closed");
|
|
90
|
-
return
|
|
91
|
-
|
|
91
|
+
return r.add(e), () => {
|
|
92
|
+
r.delete(e);
|
|
92
93
|
};
|
|
93
94
|
},
|
|
94
95
|
close: () => p ??= (async () => {
|
|
95
|
-
f = !0,
|
|
96
|
+
f = !0, t.clear(), r.clear();
|
|
96
97
|
for (let e of u.values()) {
|
|
97
98
|
e.released = !0;
|
|
98
99
|
try {
|
|
@@ -101,48 +102,47 @@ var r = new TextEncoder(), i = new TextDecoder(), a = 5e3, o = 1e3, s = async (e
|
|
|
101
102
|
}
|
|
102
103
|
u.clear();
|
|
103
104
|
try {
|
|
104
|
-
await
|
|
105
|
+
await c(e.drain(), s);
|
|
105
106
|
} catch {} finally {
|
|
106
107
|
await e.close(), await g.return?.(), await Promise.all([...l]), await _;
|
|
107
108
|
}
|
|
108
109
|
})()
|
|
109
110
|
};
|
|
110
|
-
},
|
|
111
|
-
let
|
|
112
|
-
let e = await (await import("@nats-io/transport-node")).connect({
|
|
113
|
-
servers:
|
|
111
|
+
}, u = (n) => r.callback((i) => {
|
|
112
|
+
let a = !1, s, c = (async () => {
|
|
113
|
+
let e = await (await import("@nats-io/transport-node").catch(t("@nats-io/transport-node", "A NATS connection"))).connect({
|
|
114
|
+
servers: n.url.split(",").map((e) => e.trim()),
|
|
114
115
|
maxReconnectAttempts: -1,
|
|
115
116
|
waitOnFirstConnect: !0,
|
|
116
117
|
reconnectTimeWait: 2e3,
|
|
117
|
-
timeout:
|
|
118
|
-
...
|
|
119
|
-
...
|
|
120
|
-
...
|
|
121
|
-
...
|
|
118
|
+
timeout: o,
|
|
119
|
+
...n.tls === "required" ? { tls: {} } : {},
|
|
120
|
+
...n.token === void 0 ? {} : { token: n.token },
|
|
121
|
+
...n.user === void 0 ? {} : { user: n.user },
|
|
122
|
+
...n.pass === void 0 ? {} : { pass: n.pass },
|
|
122
123
|
reconnectToServer: () => {
|
|
123
|
-
if (
|
|
124
|
+
if (a) throw Error("NATS acquisition cancelled");
|
|
124
125
|
return null;
|
|
125
126
|
}
|
|
126
127
|
});
|
|
127
|
-
if (
|
|
128
|
+
if (a) await e.close();
|
|
128
129
|
else {
|
|
129
130
|
try {
|
|
130
|
-
|
|
131
|
+
s = l(e);
|
|
131
132
|
} catch (t) {
|
|
132
133
|
throw await e.close(), t;
|
|
133
134
|
}
|
|
134
|
-
r
|
|
135
|
+
i(r.succeed(s));
|
|
135
136
|
}
|
|
136
137
|
})().catch(() => {
|
|
137
|
-
|
|
138
|
+
a || i(r.fail(new e({
|
|
138
139
|
operation: "connect",
|
|
139
140
|
key: "",
|
|
140
141
|
cause: "NATS driver could not be opened"
|
|
141
142
|
})));
|
|
142
143
|
});
|
|
143
|
-
return
|
|
144
|
-
|
|
144
|
+
return r.promise(async () => {
|
|
145
|
+
a = !0, await c, await s?.close();
|
|
145
146
|
});
|
|
146
147
|
});
|
|
147
|
-
|
|
148
|
-
export { l as connectNats };
|
|
148
|
+
export { u as connectNats };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { connectionDefinitionsProblem as e, natsConnectionName as t } from "./connectionDefinitions.js";
|
|
2
2
|
import { Config as n, ConfigProvider as r, Effect as i, Option as a } from "effect";
|
|
3
|
-
|
|
3
|
+
// src/connectionNatsConfig.ts
|
|
4
4
|
var o = (e) => e.toUpperCase().replace(/[^A-Z0-9]+/g, "_"), s = (e) => {
|
|
5
5
|
if (typeof e.url != "string" || !e.url.trim()) return "A NATS connection requires an endpoint";
|
|
6
6
|
for (let t of e.url.split(",")) try {
|
|
@@ -83,5 +83,4 @@ var o = (e) => e.toUpperCase().replace(/[^A-Z0-9]+/g, "_"), s = (e) => {
|
|
|
83
83
|
};
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
|
-
//#endregion
|
|
87
86
|
export { s as natsConfigProblem, c as natsConnectionConfig };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/connectionNatsSubjects.ts
|
|
2
2
|
var e = (e) => {
|
|
3
3
|
if (!e || /[\s*>]/u.test(e) || e.split(".").some((e) => !e)) throw Error("Registry NATS channels must be exact nonempty subjects");
|
|
4
4
|
}, t = (e, t = "") => ({
|
|
@@ -12,5 +12,4 @@ var e = (e) => {
|
|
|
12
12
|
flush: e.flush,
|
|
13
13
|
close: e.close
|
|
14
14
|
});
|
|
15
|
-
//#endregion
|
|
16
15
|
export { e as assertNatsSubject, t as withNatsSubjectPrefix };
|
package/dist/connectionOwner.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KvError as e } from "./errors.js";
|
|
2
2
|
import { Deferred as t, Effect as n, Scope as r } from "effect";
|
|
3
|
-
|
|
3
|
+
// src/connectionOwner.ts
|
|
4
4
|
var i = (i) => n.gen(function* () {
|
|
5
5
|
let a = yield* n.scope, o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = !1, l = (e) => n.uninterruptible(n.suspend(() => e.closed ? t.await(e.closedSignal) : (e.closed = !0, i.dispose(e).pipe(n.ensuring(n.sync(() => {
|
|
6
6
|
o.delete(e);
|
|
@@ -40,5 +40,4 @@ var i = (i) => n.gen(function* () {
|
|
|
40
40
|
}))
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
|
-
//#endregion
|
|
44
43
|
export { i as makeConnectionOwner };
|