@mark1russell7/harness 0.12.2 → 0.12.4

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/build/index.d.ts CHANGED
@@ -1233,8 +1233,9 @@ export declare const memberConfig: (group: Group, primary: string | null) => str
1233
1233
  export declare const sentinelConfig: (group: Group, primary: string) => string;
1234
1234
  /**
1235
1235
  * This function gives the peers that a fault on a part cuts it from, by their addresses. `all` is
1236
- * each other part and the client, `group` is the other parts, and `clients` is the client. The
1237
- * observer is not a peer, thus the timeline of the group stays whole.
1236
+ * each other part and the client, `group` is the other parts, and `clients` is the client. `one`
1237
+ * and `one-way` are the first other member. The observer is not a peer, thus the timeline of the
1238
+ * group stays whole.
1238
1239
  */
1239
1240
  export declare const peersOf: (parts: {
1240
1241
  readonly members: Readonly<Record<string, RunPart>>;
package/build/index.js CHANGED
@@ -2150,7 +2150,13 @@ const lines = (also) => {
2150
2150
  if (text.length > 0) other.push(text);
2151
2151
  return;
2152
2152
  }
2153
- const line = JSON.parse(text);
2153
+ let line;
2154
+ try {
2155
+ line = JSON.parse(text);
2156
+ } catch {
2157
+ other.push(text);
2158
+ return;
2159
+ }
2154
2160
  seen.push(line);
2155
2161
  also?.(line);
2156
2162
  for (const wait of waiting.splice(0)) if (wait.kinds.includes(line.ev)) wait.resolve(line);
@@ -3042,15 +3048,19 @@ const sentinelConfig = (group, primary) => [
3042
3048
  ].join("\n");
3043
3049
  /**
3044
3050
  * This function gives the peers that a fault on a part cuts it from, by their addresses. `all` is
3045
- * each other part and the client, `group` is the other parts, and `clients` is the client. The
3046
- * observer is not a peer, thus the timeline of the group stays whole.
3051
+ * each other part and the client, `group` is the other parts, and `clients` is the client. `one`
3052
+ * and `one-way` are the first other member. The observer is not a peer, thus the timeline of the
3053
+ * group stays whole.
3047
3054
  */
3048
3055
  const peersOf = (parts, client, part, cuts) => {
3049
3056
  const others = [...Object.entries(parts.members), ...Object.entries(parts.sentinels)].filter(([name]) => name !== part).map(([, at]) => at.ip);
3050
3057
  if (cuts === "clients") return [client];
3051
3058
  if (cuts === "group") return others;
3059
+ if (cuts === "one" || cuts === "one-way") return Object.entries(parts.members).filter(([name]) => name !== part).slice(0, 1).map(([, at]) => at.ip);
3052
3060
  return [...others, client];
3053
3061
  };
3062
+ /** This function gives the direction of the rules of a cut: `one-way` drops only the segments from the part. */
3063
+ const directionOf = (cuts) => cuts === "one-way" ? ["--direction", "out"] : [];
3054
3064
  /** This function reads the flat reply of a command line client into its fields: name, value, name, value. */
3055
3065
  const fieldsOf = (text) => {
3056
3066
  const out = [];
@@ -3385,6 +3395,7 @@ const openGroupLab = async (group, options = {}) => {
3385
3395
  "/opt/harness/inject",
3386
3396
  kind,
3387
3397
  peers,
3398
+ ...directionOf(cuts),
3388
3399
  ...after(at)
3389
3400
  ]);
3390
3401
  },
@@ -3394,6 +3405,7 @@ const openGroupLab = async (group, options = {}) => {
3394
3405
  "/opt/harness/inject",
3395
3406
  kind === "rst" ? "clear-rst" : "clear",
3396
3407
  peers,
3408
+ ...directionOf(cuts),
3397
3409
  ...after(at)
3398
3410
  ]);
3399
3411
  },