querysub 0.679.0 → 0.680.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.679.0",
3
+ "version": "0.680.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",
@@ -14,9 +14,12 @@ export type ArchiveT<T> = {
14
14
  [Symbol.asyncIterator](): AsyncIterator<[string, T]>;
15
15
  };
16
16
 
17
- export function archiveJSONT<T>(archives: () => IArchives, config?: { fallbacks?: boolean }): ArchiveT<T> {
17
+ export function archiveJSONT<T>(archives: () => IArchives, config?: { setFallbacks?: boolean; findFallbacks?: boolean }): ArchiveT<T> {
18
18
  archives = lazy(archives);
19
19
 
20
+ let setConfig: SetConfig = { fallbacks: config?.setFallbacks };
21
+ let findConfig: FindConfig = { fallbacks: config?.findFallbacks };
22
+
20
23
  let valuesCache = new Map<string, {
21
24
  createTime: number;
22
25
  size: number;
@@ -31,7 +34,7 @@ export function archiveJSONT<T>(archives: () => IArchives, config?: { fallbacks?
31
34
  async function set(key: string, value: T) {
32
35
  let a = archives();
33
36
  console.log(`In archiveJSONT ${a.getDebugName()}, setting ${key} to ${JSON.stringify(value)}`);
34
- await a.set(key, Buffer.from(JSON.stringify(value)), config);
37
+ await a.set(key, Buffer.from(JSON.stringify(value)), setConfig);
35
38
  }
36
39
  async function deleteFnc(key: string) {
37
40
  let a = archives();
@@ -39,10 +42,10 @@ export function archiveJSONT<T>(archives: () => IArchives, config?: { fallbacks?
39
42
  await a.del(key);
40
43
  }
41
44
  async function keys() {
42
- return (await archives().find("", config)).map(value => value.toString());
45
+ return (await archives().find("", findConfig)).map(value => value.toString());
43
46
  }
44
47
  async function values() {
45
- let infos = await archives().findInfo("", config);
48
+ let infos = await archives().findInfo("", findConfig);
46
49
 
47
50
  let needsUpdate = false;
48
51
  let currentKeys = new Set(infos.map(info => info.path));
@@ -64,7 +67,7 @@ export function archiveJSONT<T>(archives: () => IArchives, config?: { fallbacks?
64
67
  let maxRetries = 10;
65
68
  let updated = false;
66
69
  for (let attempt = 0; attempt < maxRetries; attempt++) {
67
- infos = await archives().findInfo("", config);
70
+ infos = await archives().findInfo("", findConfig);
68
71
 
69
72
  let newCache = new Map<string, {
70
73
  createTime: number;
@@ -93,7 +96,7 @@ export function archiveJSONT<T>(archives: () => IArchives, config?: { fallbacks?
93
96
 
94
97
  if (!allFound) continue;
95
98
 
96
- let newInfos = await archives().findInfo("", config);
99
+ let newInfos = await archives().findInfo("", findConfig);
97
100
  if (newInfos.length !== infos.length) continue;
98
101
  function anyChanged() {
99
102
  for (let i = 0; i < newInfos.length; i++) {
@@ -304,7 +304,7 @@ async function updateEdgeNodesFile() {
304
304
  }
305
305
  }
306
306
 
307
- let edgeNodeFiles = await edgeNodeStorage.find("node", { type: "files" });
307
+ let edgeNodeFiles = await edgeNodeStorage.find("node", { type: "files", fallbacks: true });
308
308
  // Reads are independent, so run them in parallel (bounded): with many files a serial pass would take files × read-latency, which could be minutes.
309
309
  let readEdgeNodeFile = runInParallel({ parallelCount: EDGE_NODE_READ_PARALLEL }, async (nodeFile: string) => {
310
310
  let buffer = await edgeNodeStorage.get(nodeFile);
@@ -35,9 +35,9 @@ export type MachineConfig = {
35
35
  disabled: boolean;
36
36
  };
37
37
  // We want all of these to have very high availability. Even if they're wrong, it's better to have an old service deployed or even view information on an old service, or even set information only in back plays rather than have the server be completely down.
38
- export const machineInfos = archiveJSONT<MachineInfo>(() => getArchives2("machines/machine-heartbeats/"), { fallbacks: true });
39
- export const serviceConfigs = archiveJSONT<ServiceConfig>(() => getArchives2("machines/service-configs/"), { fallbacks: true });
40
- export const machineConfigs = archiveJSONT<MachineConfig>(() => getArchives2("machines/machine-configs/"), { fallbacks: true });
38
+ export const machineInfos = archiveJSONT<MachineInfo>(() => getArchives2("machines/machine-heartbeats/"), { setFallbacks: true, findFallbacks: true });
39
+ export const serviceConfigs = archiveJSONT<ServiceConfig>(() => getArchives2("machines/service-configs/"), { setFallbacks: true, findFallbacks: true });
40
+ export const machineConfigs = archiveJSONT<MachineConfig>(() => getArchives2("machines/machine-configs/"), { setFallbacks: true, findFallbacks: true });
41
41
 
42
42
  export type MachineInfo = {
43
43
  machineId: string;
@@ -557,7 +557,7 @@ export class MachineServiceControllerBase {
557
557
  for (let i = 0; i <= sinceDays; i++) {
558
558
  dayStrings.push(formatLaunchDay(now - i * timeInDay));
559
559
  }
560
- let keyLists = await Promise.all(dayStrings.map(day => launches().find(`${day}/`)));
560
+ let keyLists = await Promise.all(dayStrings.map(day => launches().find(`${day}/`, { fallbacks: true })));
561
561
  let summaries: LaunchSummary[] = [];
562
562
  for (let keys of keyLists) {
563
563
  for (let key of keys) {
@@ -36,7 +36,7 @@ export type SuppressionEntry = {
36
36
  createdTime: number;
37
37
  lastUpdatedTime: number;
38
38
  };
39
- const suppression = archiveJSONT<SuppressionEntry>(() => getArchives2("logs/error-suppression/"));
39
+ const suppression = archiveJSONT<SuppressionEntry>(() => getArchives2("logs/error-suppression/"), { findFallbacks: true });
40
40
 
41
41
  // In-memory Discord notification throttling
42
42
  const timeInHour = 60 * 60 * 1000;
@@ -13,7 +13,7 @@ import { Ticket, TicketComment, TicketPatchStatus, TicketState } from "./ticketT
13
13
 
14
14
  const TICKET_CACHE_POLL_INTERVAL = timeInMinute * 5;
15
15
 
16
- export const ticketsArchive = archiveJSONT<Ticket>(() => getArchives2("logs/error-tickets/"));
16
+ export const ticketsArchive = archiveJSONT<Ticket>(() => getArchives2("logs/error-tickets/"), { findFallbacks: true });
17
17
 
18
18
  let ticketCache = new Map<string, Ticket>();
19
19
  let ensureWatching = lazy(async () => {
@@ -54,7 +54,7 @@ export function getVariables(entry: LifeCycleEntry): { key: string, title?: stri
54
54
  return variables;
55
55
  }
56
56
 
57
- const lifeCycles = archiveJSONT<LifeCycle>(() => getArchives2("logs/life-cycles/"));
57
+ const lifeCycles = archiveJSONT<LifeCycle>(() => getArchives2("logs/life-cycles/"), { findFallbacks: true });
58
58
  let lifeCyclesCache: LifeCycle[] = [];
59
59
 
60
60
  let ensureWatching = lazy(async () => {