querysub 0.440.0 → 0.441.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "querysub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.441.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"node-forge": "https://github.com/sliftist/forge#e618181b469b07bdc70b968b0391beb8ef5fecd6",
|
|
62
62
|
"pako": "^2.1.0",
|
|
63
63
|
"peggy": "^5.0.6",
|
|
64
|
-
"socket-function": "^1.1.
|
|
64
|
+
"socket-function": "^1.1.23",
|
|
65
65
|
"terser": "^5.31.0",
|
|
66
66
|
"typesafecss": "^0.29.0",
|
|
67
67
|
"yaml": "^2.5.0",
|
|
@@ -1192,7 +1192,7 @@ export class PathValueProxyWatcher {
|
|
|
1192
1192
|
};
|
|
1193
1193
|
watcher.hasAnyUnsyncedAccesses = () => {
|
|
1194
1194
|
if (watcher.options.waitForIncompleteTransactions) {
|
|
1195
|
-
waitIfReceivedIncompleteTransaction();
|
|
1195
|
+
waitIfReceivedIncompleteTransaction(watcher);
|
|
1196
1196
|
}
|
|
1197
1197
|
return (
|
|
1198
1198
|
watcher.pendingUnsyncedAccesses.size > 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { delay } from "socket-function/src/batching";
|
|
2
2
|
import { PathValue, hashPathForTransaction, compareTime, Time } from "../0-path-value-core/pathValueCore";
|
|
3
|
-
import { proxyWatcher } from "./PathValueProxyWatcher";
|
|
3
|
+
import { SyncWatcher, proxyWatcher } from "./PathValueProxyWatcher";
|
|
4
4
|
|
|
5
5
|
const MISSING_TRANSACTION_PART_TIMEOUT = 5000;
|
|
6
6
|
|
|
@@ -62,9 +62,8 @@ export function isMissingTransactionPart(pathValues: PathValue[]): { time: numbe
|
|
|
62
62
|
return newestWaitTime;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export function getAllPendingPathValueReads() {
|
|
65
|
+
export function getAllPendingPathValueReads(watcher = proxyWatcher.getTriggeredWatcher()) {
|
|
66
66
|
let values: PathValue[] = [];
|
|
67
|
-
let watcher = proxyWatcher.getTriggeredWatcher();
|
|
68
67
|
for (let map of watcher.pendingAccesses.values()) {
|
|
69
68
|
for (let pathValue of map.values()) {
|
|
70
69
|
values.push(pathValue.pathValue);
|
|
@@ -74,13 +73,11 @@ export function getAllPendingPathValueReads() {
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
|
|
77
|
-
export function waitIfReceivedIncompleteTransaction() {
|
|
78
|
-
// 1) Keep track of the last proxy watcher we just registered it for. And then if the proxy watcher is the same as that one and that proxy watcher is waiting on a promise, don't register it again.
|
|
79
|
-
let watcher = proxyWatcher.getTriggeredWatcher();
|
|
76
|
+
export function waitIfReceivedIncompleteTransaction(watcher: SyncWatcher) {
|
|
80
77
|
// We don't want to register a whole bunch of duplicate promises. So if somebody's waiting, there's no need to even do our check.
|
|
81
78
|
if (watcher.specialPromiseUnsynced) return;
|
|
82
79
|
|
|
83
|
-
let newestTime = isMissingTransactionPart(getAllPendingPathValueReads());
|
|
80
|
+
let newestTime = isMissingTransactionPart(getAllPendingPathValueReads(watcher));
|
|
84
81
|
if (!newestTime) return;
|
|
85
82
|
|
|
86
83
|
let timeout = newestTime.time + MISSING_TRANSACTION_PART_TIMEOUT;
|
|
@@ -183,6 +183,9 @@ export class Querysub {
|
|
|
183
183
|
public static AUDIT_PREDICTIONS = true;
|
|
184
184
|
public static SIMULATE_LAG = 0;
|
|
185
185
|
|
|
186
|
+
public static registerAliveChecker = <T>(config: AliveChecker<T>) => registerAliveChecker(config);
|
|
187
|
+
public static registerGarbageCollection = <T>(config: AliveChecker<T>) => registerAliveChecker(config);
|
|
188
|
+
|
|
186
189
|
/** Delay used when functions are specified as delayCommit */
|
|
187
190
|
public static DELAY_COMMIT_DELAY = 1000 * 3;
|
|
188
191
|
|
|
@@ -1339,4 +1342,5 @@ import { onAllPredictionsFinished } from "../-0-hooks/hooks";
|
|
|
1339
1342
|
import { LOCAL_DOMAIN } from "../0-path-value-core/PathRouter";
|
|
1340
1343
|
import { authorityLookup } from "../0-path-value-core/AuthorityLookup";
|
|
1341
1344
|
import { encodeParentFilter } from "../0-path-value-core/hackedPackedPathParentFiltering";
|
|
1345
|
+
import { AliveChecker, registerAliveChecker } from "../2-proxy/garbageCollection";
|
|
1342
1346
|
|
|
@@ -756,14 +756,20 @@ export class IndexedLogs<T> {
|
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
|
|
759
|
+
|
|
760
|
+
function getLogByName(name: string): IndexedLogs<unknown> {
|
|
761
|
+
let indexedLogs = loggerByName.get(name);
|
|
762
|
+
if (!indexedLogs) throw new Error(`Indexed logs ${name} not found, have ${Array.from(loggerByName.keys()).join(" | ")}`);
|
|
763
|
+
return indexedLogs;
|
|
764
|
+
}
|
|
759
765
|
class IndexedLogClient {
|
|
766
|
+
|
|
760
767
|
public async onFind(config: {
|
|
761
768
|
findId: string;
|
|
762
769
|
indexedLogsName: string;
|
|
763
770
|
result: unknown;
|
|
764
771
|
}) {
|
|
765
|
-
let indexedLogs =
|
|
766
|
-
if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
|
|
772
|
+
let indexedLogs = getLogByName(config.indexedLogsName);
|
|
767
773
|
indexedLogs.onFindResult({
|
|
768
774
|
findId: config.findId,
|
|
769
775
|
result: config.result,
|
|
@@ -774,8 +780,7 @@ class IndexedLogClient {
|
|
|
774
780
|
indexedLogsName: string;
|
|
775
781
|
results: IndexedLogResults;
|
|
776
782
|
}): Promise<boolean> {
|
|
777
|
-
let indexedLogs =
|
|
778
|
-
if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
|
|
783
|
+
let indexedLogs = getLogByName(config.indexedLogsName);
|
|
779
784
|
return await indexedLogs.onResults({
|
|
780
785
|
findId: config.findId,
|
|
781
786
|
results: config.results,
|
|
@@ -789,8 +794,7 @@ class IndexedLogShim {
|
|
|
789
794
|
params: SearchParams;
|
|
790
795
|
}): Promise<IndexedLogResults> {
|
|
791
796
|
let caller = SocketFunction.getCaller();
|
|
792
|
-
let indexedLogs =
|
|
793
|
-
if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
|
|
797
|
+
let indexedLogs = getLogByName(config.indexedLogsName);
|
|
794
798
|
|
|
795
799
|
return indexedLogs.find({
|
|
796
800
|
params: config.params,
|
|
@@ -822,8 +826,7 @@ class IndexedLogShim {
|
|
|
822
826
|
only?: "local" | "public";
|
|
823
827
|
forceReadProduction?: boolean;
|
|
824
828
|
}): Promise<TimeFilePathWithSize[]> {
|
|
825
|
-
let indexedLogs =
|
|
826
|
-
if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
|
|
829
|
+
let indexedLogs = getLogByName(config.indexedLogsName);
|
|
827
830
|
return indexedLogs.getPaths({
|
|
828
831
|
startTime: config.startTime,
|
|
829
832
|
endTime: config.endTime,
|
|
@@ -835,8 +838,7 @@ class IndexedLogShim {
|
|
|
835
838
|
public async forceMoveLogsToPublic(config: {
|
|
836
839
|
indexedLogsName: string;
|
|
837
840
|
}) {
|
|
838
|
-
let indexedLogs =
|
|
839
|
-
if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
|
|
841
|
+
let indexedLogs = getLogByName(config.indexedLogsName);
|
|
840
842
|
await indexedLogs.moveLogsToPublic(true);
|
|
841
843
|
}
|
|
842
844
|
|