fleetfizz 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/fleetfizz.mjs +43 -3
  2. package/package.json +1 -1
@@ -6708,6 +6708,8 @@ const tapEffectCont = function(value) {
6708
6708
  return new ContImpl(this.payload, succeedPayload, value);
6709
6709
  };
6710
6710
  /** @internal */
6711
+ const asSome = (self) => map$7(self, some);
6712
+ /** @internal */
6711
6713
  const andThen$1 = /*#__PURE__*/ dual(2, (self, f) => new ContImpl(self, isEffect$1(f) ? returnPayload : andThenCont, f));
6712
6714
  /** @internal */
6713
6715
  const tap$1 = /*#__PURE__*/ dual(2, (self, f) => new ContImpl(self, isEffect$1(f) ? tapEffectCont : tapCont, f));
@@ -6959,6 +6961,10 @@ const exitPrimitive = /*#__PURE__*/ makePrimitive$1({
6959
6961
  }
6960
6962
  });
6961
6963
  /** @internal */
6964
+ const timeoutOrElse$1 = /*#__PURE__*/ dual(2, (self, options) => flatMap$2(timeoutOption(self, options.duration), (option) => isNone(option) ? options.orElse() : succeed$6(option.value)));
6965
+ /** @internal */
6966
+ const timeoutOption = /*#__PURE__*/ dual(2, (self, duration) => raceFirst$1(asSome(self), as$1(sleep$1(duration), none())));
6967
+ /** @internal */
6962
6968
  const ScopeTypeId = "~effect/Scope";
6963
6969
  /** @internal */
6964
6970
  const ScopeCloseableTypeId = "~effect/Scope/Closeable";
@@ -11106,6 +11112,35 @@ const ignore = ignore$1;
11106
11112
  */
11107
11113
  const orElseSucceed = orElseSucceed$1;
11108
11114
  /**
11115
+ * Applies a timeout to an effect, lazily evaluating `orElse` after interrupting
11116
+ * the source if the timeout is reached.
11117
+ *
11118
+ * **Example** (Falling back on timeout)
11119
+ *
11120
+ * ```ts import.meta.vitest
11121
+ * import { Effect } from "effect"
11122
+ * const output: Array<unknown> = []
11123
+ *
11124
+ * const program = Effect.timeoutOrElse(Effect.never, {
11125
+ * duration: 0,
11126
+ * orElse: () => Effect.sync(() => { output.push("Query timed out, using cached data") }).pipe(
11127
+ * Effect.as("Cached result")
11128
+ * )
11129
+ * })
11130
+ *
11131
+ * void output.push(await Effect.runPromise(program))
11132
+ * output // => ["Query timed out, using cached data", "Cached result"]
11133
+ * ```
11134
+ *
11135
+ * @see {@link timeout} for failing with a `TimeoutError`.
11136
+ * @see {@link timeoutOption} for returning `Option.none` on timeout.
11137
+ *
11138
+ * @stability stable
11139
+ * @category delays & timeouts
11140
+ * @since 4.0.0
11141
+ */
11142
+ const timeoutOrElse = timeoutOrElse$1;
11143
+ /**
11109
11144
  * Returns an effect that suspends the current fiber for the specified duration
11110
11145
  * without blocking a JavaScript thread.
11111
11146
  *
@@ -31684,7 +31719,7 @@ const runWith = (command, config) => {
31684
31719
  };
31685
31720
  //#endregion
31686
31721
  //#region package.json
31687
- var version = "0.2.0";
31722
+ var version = "0.2.1";
31688
31723
  //#endregion
31689
31724
  //#region ../../node_modules/.pnpm/effect@4.0.2/node_modules/effect/dist/Ref.js
31690
31725
  /**
@@ -35404,7 +35439,8 @@ const command = (target, script, secrets) => {
35404
35439
  const options = {
35405
35440
  stdin: encodeText(make$18(secrets.map((s) => `${s}\n`).join(""))),
35406
35441
  stdout: "pipe",
35407
- stderr: "pipe"
35442
+ stderr: "pipe",
35443
+ forceKillAfter: "5 seconds"
35408
35444
  };
35409
35445
  return target.local ? make$13(process.env.SHELL ?? "/bin/sh", ["-lc", script], options) : make$13("tailscale", [
35410
35446
  "ssh",
@@ -35512,13 +35548,17 @@ const runOn = fn("runOn")(function* (target, script, secrets, onLine, ledger) {
35512
35548
  }
35513
35549
  return run;
35514
35550
  });
35551
+ const GATHER_TIMEOUT = "2 minutes";
35515
35552
  const gather = fn("gather")(function* (target, script, ledger) {
35516
35553
  const facts = [];
35517
35554
  const output = [];
35518
35555
  const run = yield* runOn(target, script, [], (line) => sync(() => {
35519
35556
  if (line.kind === "state") facts.push(line.fact);
35520
35557
  else if (line.kind === "text" && line.text.trim() !== "") output.push(line.text.trimEnd());
35521
- }), ledger);
35558
+ }), ledger).pipe(timeoutOrElse({
35559
+ duration: GATHER_TIMEOUT,
35560
+ orElse: () => ledger.fail(target.name, [`gather took more than ${GATHER_TIMEOUT}; something on that Machine is blocking`, ...output]).pipe(as({ kind: "failed" }))
35561
+ }));
35522
35562
  if (run.kind !== "ran") return { kind: run.kind };
35523
35563
  const state = assembleState(facts);
35524
35564
  if (!state.complete) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetfizz",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Keep every Machine on your tailnet in line with one config.",
5
5
  "license": "MIT",
6
6
  "repository": {