querysub 0.678.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.678.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);
package/src/config.ts CHANGED
@@ -32,8 +32,8 @@ let yargObj = parseArgsFactory()
32
32
  })
33
33
  .option("logbackblaze", { type: "boolean", desc: "Log all backblaze activity to disk." })
34
34
  .option("slowdown", { type: "number", desc: "Delay all input data values by this amount of time, pretending like we didn't even receive it until this time is up." })
35
- .option("network", { type: "array", desc: `The networks this node is on (pass multiple arguments to be on multiple, ex: --network test --network default). Authorities only satisfy paths on their networks ("default" if unset). Function calls are put on the first network in the list. If no FunctionRunner is on a call's network, the call will fail to run.` })
36
- .option("networkfile", { type: "string", desc: `The same as --network, except the networks are read from the given file (one per line). Supports "~/" for the home directory. If the file doesn't exist, the process exits with an error.` })
35
+ .option("network", { type: "array", desc: `The networks this node is on (pass multiple arguments to be on multiple, ex: --network test --network default, or comma separate them: --network test,default). Authorities only satisfy paths on their networks ("default" if unset). Function calls are put on the first network in the list. If no FunctionRunner is on a call's network, the call will fail to run.` })
36
+ .option("networkfile", { type: "string", desc: `The same as --network, except the networks are read from the given file (one per line, and commas separate as well). Supports "~/" for the home directory. If the file doesn't exist, the process exits with an error.` })
37
37
  .option("port", { type: "number", desc: "The storage port for `yarn storageserve`" })
38
38
  .argv
39
39
  ;
@@ -62,7 +62,7 @@ let networkFileNetworks = lazy((): string[] => {
62
62
  console.error(`--networkfile file not found: ${path}`);
63
63
  process.exit(1);
64
64
  }
65
- return fs.readFileSync(path, "utf8").split("\n").map(x => x.trim()).filter(x => x);
65
+ return fs.readFileSync(path, "utf8").split(/[\n,]/).map(x => x.trim()).filter(x => x);
66
66
  });
67
67
 
68
68
  /** The networks a function runner listens on, from the command line (--network / --networkfile). */
@@ -73,7 +73,8 @@ export function getNetworks(): string[] {
73
73
  } else if (!Array.isArray(networks)) {
74
74
  networks = [networks];
75
75
  }
76
- let result = networks.map(x => String(x));
76
+ // Comma separated is the same as repeating the flag, so a templated list of networks can be passed as one argument.
77
+ let result = networks.flatMap(x => String(x).split(",")).map(x => x.trim()).filter(x => x);
77
78
  if (isNode()) {
78
79
  result = [...result, ...networkFileNetworks()];
79
80
  }
@@ -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 () => {