@deslop/deploy 0.1.1354 → 0.1.1356

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/dist/server.js CHANGED
@@ -8909,7 +8909,7 @@ const Order$6 = /*#__PURE__*/ make$94((self, that) => matchPair(self, that, {
8909
8909
  * @category instances
8910
8910
  * @since 2.0.0
8911
8911
  */
8912
- const Equivalence$3 = (self, that) => matchPair(self, that, {
8912
+ const Equivalence$5 = (self, that) => matchPair(self, that, {
8913
8913
  onMillis: (self, that) => self === that,
8914
8914
  onNanos: (self, that) => self === that,
8915
8915
  onInfinity: (self, that) => self.value._tag === that.value._tag
@@ -9172,7 +9172,7 @@ const isGreaterThanOrEqualTo$3 = /*#__PURE__*/ isGreaterThanOrEqualTo$4(Order$6)
9172
9172
  * @category predicates
9173
9173
  * @since 2.0.0
9174
9174
  */
9175
- const equals = /*#__PURE__*/ dual(2, (self, that) => Equivalence$3(self, that));
9175
+ const equals = /*#__PURE__*/ dual(2, (self, that) => Equivalence$5(self, that));
9176
9176
  /**
9177
9177
  * Decomposes a `Duration` into normalized signed components.
9178
9178
  *
@@ -11911,6 +11911,8 @@ const onErrorFilter = /*#__PURE__*/ dual(3, (self, filter, f) => onExit$2(self,
11911
11911
  const onInterrupt$1 = /*#__PURE__*/ dual(2, (self, finalizer) => onErrorFilter(causeFilterInterruptors, finalizer)(self));
11912
11912
  /** @internal */
11913
11913
  const acquireUseRelease$1 = (acquire, use, release) => uninterruptibleMask$1((restore) => flatMap$5(acquire, (a) => onExitPrimitive$1(suspend$4(() => restore(use(a))), (exit) => release(a, exit), true)));
11914
+ /** @internal */
11915
+ const cachedInvalidateWithTTL$1 = /*#__PURE__*/ dual(2, (self, ttl) => sync$2(() => makeCachedUnsafe(self, typeof ttl === "function" ? (exit) => toMillis(fromInputUnsafe$1(ttl(exit))) : constant(toMillis(fromInputUnsafe$1(ttl))))));
11914
11916
  const infiniteTTL = /*#__PURE__*/ constant(Infinity);
11915
11917
  const makeCachedUnsafe = (self, ttlMillis) => {
11916
11918
  let expiresAt = 0;
@@ -16434,6 +16436,8 @@ const isUtc$1 = (self) => self._tag === "Utc";
16434
16436
  /** @internal */
16435
16437
  const isZoned = (self) => self._tag === "Zoned";
16436
16438
  /** @internal */
16439
+ const Equivalence$4 = /*#__PURE__*/ make$95((a, b) => a.epochMilliseconds === b.epochMilliseconds);
16440
+ /** @internal */
16437
16441
  const Order$5 = /*#__PURE__*/ make$94((self, that) => self.epochMilliseconds < that.epochMilliseconds ? -1 : self.epochMilliseconds > that.epochMilliseconds ? 1 : 0);
16438
16442
  const makeUtc = (epochMillis) => {
16439
16443
  const self = Object.create(ProtoUtc);
@@ -22174,6 +22178,66 @@ const onExit$1 = onExit$2;
22174
22178
  */
22175
22179
  const cached = cached$1;
22176
22180
  /**
22181
+ * Creates a cached effect result for a fixed duration or a duration computed
22182
+ * from its `Exit` and allows manual invalidation before expiration.
22183
+ *
22184
+ * **When to use**
22185
+ *
22186
+ * Use when an effect result should be cached for a bounded time and callers
22187
+ * also need a manual invalidation effect to force recomputation before
22188
+ * expiration.
22189
+ *
22190
+ * **Details**
22191
+ *
22192
+ * This function behaves similarly to {@link cachedWithTTL} by caching the
22193
+ * result of an effect for a specified period of time. However, it introduces an
22194
+ * additional feature: it provides an effect that allows you to manually
22195
+ * invalidate the cached result before it naturally expires.
22196
+ *
22197
+ * This gives you more control over the cache, allowing you to refresh the
22198
+ * result when needed, even if the original cache has not yet expired.
22199
+ *
22200
+ * Once the cache is invalidated, the next time the effect is evaluated, the
22201
+ * result will be recomputed, and the cache will be refreshed.
22202
+ *
22203
+ * **Example** (Memoizing with TTL and invalidation)
22204
+ *
22205
+ * ```ts import.meta.vitest
22206
+ * import { Effect } from "effect"
22207
+ * const output: Array<unknown> = []
22208
+ * const record = (value: unknown) => Effect.sync(() => { output.push(value) })
22209
+ *
22210
+ * let i = 1
22211
+ * const expensiveTask = Effect.sync(() => {
22212
+ * void output.push("expensive task...")
22213
+ * return `result ${i++}`
22214
+ * })
22215
+ *
22216
+ * const program = Effect.gen(function*() {
22217
+ * const [cached, invalidate] = yield* Effect.cachedInvalidateWithTTL(
22218
+ * expensiveTask,
22219
+ * "1 hour"
22220
+ * )
22221
+ * yield* cached.pipe(Effect.andThen(record))
22222
+ * yield* cached.pipe(Effect.andThen(record))
22223
+ * yield* invalidate
22224
+ * yield* cached.pipe(Effect.andThen(record))
22225
+ * })
22226
+ *
22227
+ * Effect.runSync(program)
22228
+ * output // => ["expensive task...", "result 1", "result 1", "expensive task...", "result 2"]
22229
+ * ```
22230
+ *
22231
+ * @see {@link cached} for a similar function that caches the result
22232
+ * indefinitely.
22233
+ * @see {@link cachedWithTTL} for a similar function that caches the result for
22234
+ * a specified duration but does not include an effect for manual invalidation.
22235
+ * @stability stable
22236
+ * @category caching
22237
+ * @since 2.0.0
22238
+ */
22239
+ const cachedInvalidateWithTTL = cachedInvalidateWithTTL$1;
22240
+ /**
22177
22241
  * Returns an effect that is immediately interrupted.
22178
22242
  *
22179
22243
  * **Example** (Creating an interrupted effect)
@@ -29956,6 +30020,32 @@ const isDateTime = isDateTime$1;
29956
30020
  */
29957
30021
  const isUtc = isUtc$1;
29958
30022
  /**
30023
+ * Provides an `Equivalence` for comparing two `DateTime` values for equality.
30024
+ *
30025
+ * **Details**
30026
+ *
30027
+ * Two `DateTime` values are considered equivalent if they represent the same
30028
+ * point in time, regardless of their time zone.
30029
+ *
30030
+ * **Example** (Comparing DateTime values for equivalence)
30031
+ *
30032
+ * ```ts import.meta.vitest
30033
+ * import { DateTime } from "effect"
30034
+ *
30035
+ * const utc = DateTime.makeUnsafe("2024-01-01T12:00:00Z")
30036
+ * const zoned = DateTime.makeZonedUnsafe("2024-01-01T12:00:00Z", {
30037
+ * timeZone: "Europe/London"
30038
+ * })
30039
+ *
30040
+ * DateTime.Equivalence(utc, zoned) // => true
30041
+ * ```
30042
+ *
30043
+ * @stability stable
30044
+ * @category instances
30045
+ * @since 3.6.0
30046
+ */
30047
+ const Equivalence$3 = Equivalence$4;
30048
+ /**
29959
30049
  * Provides an `Order` for comparing and sorting `DateTime` values.
29960
30050
  *
29961
30051
  * **Details**
@@ -110682,7 +110772,7 @@ const RUNTIME_PATH = "/api/runtime";
110682
110772
  const RuntimeConfig = Struct$2({
110683
110773
  auth: OptionFromOptionalKey(Origin),
110684
110774
  name: String$6,
110685
- traces: String$6,
110775
+ traces: OptionFromOptionalKey(Origin),
110686
110776
  version: AppVersion
110687
110777
  });
110688
110778
  const RPC_PATH = "/api/rpc";
@@ -111646,7 +111736,7 @@ const layerTelemetry = unwrap$8(gen(function* () {
111646
111736
  const layerRoutes = use((router) => gen(function* () {
111647
111737
  const auth = yield* Auth;
111648
111738
  const issuer = yield* option(String$5("AUTH_URL"));
111649
- const traces = yield* withDefault$2(String$5("OTEL_URL"), "");
111739
+ const traces = yield* option(String$5("OTEL_URL"));
111650
111740
  const canonical = yield* String$5("APP_URL");
111651
111741
  const metadata = yield* cached(packageMetadata);
111652
111742
  yield* router.add("GET", RUNTIME_PATH, gen(function* () {
@@ -114000,8 +114090,8 @@ function processReadings(current, previous) {
114000
114090
  readings: processUsage(current, map$13(previous, (cached) => cached.baseline))
114001
114091
  };
114002
114092
  }
114003
- function launchdProcesses(text, agents) {
114004
- const rows = getSomes(pipe(text, split$1("\n"), map$10((line) => flatMap$8(match$2(/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(\S+)\s+(\S+\s+\S+\s+\S+\s+\S+\s+\S+)\s+(.*)$/u)(line), (match) => map$13(all$4({
114093
+ function launchdRows(text) {
114094
+ return getSomes(pipe(text, split$1("\n"), map$10((line) => flatMap$8(match$2(/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(\S+)\s+(\S+\s+\S+\s+\S+\s+\S+\s+\S+)\s+(.*)$/u)(line), (match) => map$13(all$4({
114005
114095
  memory: decodeOption(ResidentMemoryFromKiB)(match[3] ?? ""),
114006
114096
  parent: decodeOption(ProcessIdFromString)(match[2] ?? ""),
114007
114097
  pid: decodeOption(ProcessIdFromString)(match[1] ?? "")
@@ -114011,6 +114101,12 @@ function launchdProcesses(text, agents) {
114011
114101
  cpu: match[4] ?? "",
114012
114102
  start: match[5] ?? ""
114013
114103
  }))))));
114104
+ }
114105
+ function launchdStarts(text) {
114106
+ return fromIterable$5(map$10(launchdRows(text), (row) => [row.pid, row.start]));
114107
+ }
114108
+ function launchdProcesses(text, agents) {
114109
+ const rows = launchdRows(text);
114014
114110
  const parents = fromIterable$5(map$10(rows, (row) => [row.pid, row.parent]));
114015
114111
  function agent(pid, visited = empty$5()) {
114016
114112
  if (has(visited, pid)) return none();
@@ -114178,7 +114274,7 @@ function probeSocket(listener, process) {
114178
114274
  return listener.protocol === "tcp" && listener.port >= 1024 && isSome(match$2(/^(?:127\.0\.0\.1|0\.0\.0\.0):/u)(listener.address)) && isNone(match$2(/^(?:postgres|redis|ssh|cloudflared|tailscaled|caddy)$/u)(process));
114179
114275
  }
114180
114276
  // src/services/inventory/service.ts
114181
- function portItems(sockets, worker, http, source) {
114277
+ function portItems(sockets, worker, probe, source) {
114182
114278
  return gen(function* () {
114183
114279
  const metadata = fromIterable$5(yield* pipe(getSomes(map$10(sockets, (socket) => socket.process)), dedupeWith((left, right) => left.pid === right.pid), forEach$1(fnUntraced(function* (process) {
114184
114280
  return [process.pid, {
@@ -114186,6 +114282,7 @@ function portItems(sockets, worker, http, source) {
114186
114282
  onFalse: () => succeedNone,
114187
114283
  onTrue: () => source.cwd(process.pid)
114188
114284
  }),
114285
+ start: yield* source.start(process.pid),
114189
114286
  unit: yield* source.unit(process.pid)
114190
114287
  }];
114191
114288
  }), { concurrency: 8 })));
@@ -114201,20 +114298,13 @@ function portItems(sockets, worker, http, source) {
114201
114298
  });
114202
114299
  const response = yield* match(probeSocket(socket, getOrElse$1(process, constant(""))), {
114203
114300
  onFalse: () => succeed$5(none()),
114204
- onTrue: fnUntraced(function* () {
114205
- return yield* pipe(http.head(`http://127.0.0.1:${socket.port}/`, { headers: toHeaders(new NativeSpan({
114206
- annotations: empty$18(),
114207
- kind: "internal",
114208
- links: [],
114209
- name: "Deploy.probe",
114210
- parent: none(),
114211
- sampled: false,
114212
- startTime: 0n
114213
- })) }), map$7((value) => ({
114214
- http: true,
114215
- ui: value.status >= 200 && value.status < 400 && includes("text/html")(value.headers["content-type"] ?? "")
114216
- })), provideService$2(RequestInit, { redirect: "manual" }), provideService$2(TracerDisabledWhen, constTrue), timeout(millis(700)), option$1);
114217
- })
114301
+ onTrue: () => probe(socket.port, match$8(socket.process, {
114302
+ onNone: constant(""),
114303
+ onSome: (listener) => pipe(origin, flatMap$8((value) => value.start), match$8({
114304
+ onNone: constant(""),
114305
+ onSome: (start) => `${listener.pid}:${start}`
114306
+ }))
114307
+ }))
114218
114308
  });
114219
114309
  return InventoryItem.make({
114220
114310
  address: some$1(socket.address),
@@ -114276,6 +114366,31 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114276
114366
  const worker = yield* decodeEffect(WorkerId)(hostname());
114277
114367
  const selfProcess = yield* decodeEffect(ProcessId)(pid);
114278
114368
  const processState = yield* make$56(none());
114369
+ function head(port) {
114370
+ return pipe(http.head(`http://127.0.0.1:${port}/`, { headers: toHeaders(new NativeSpan({
114371
+ annotations: empty$18(),
114372
+ kind: "internal",
114373
+ links: [],
114374
+ name: "Deploy.probe",
114375
+ parent: none(),
114376
+ sampled: false,
114377
+ startTime: 0n
114378
+ })) }), map$7((value) => ({
114379
+ http: true,
114380
+ ui: value.status >= 200 && value.status < 400 && includes("text/html")(value.headers["content-type"] ?? "")
114381
+ })), provideService$2(RequestInit, { redirect: "manual" }), provideService$2(TracerDisabledWhen, constTrue), timeout(millis(700)), option$1);
114382
+ }
114383
+ const probes = yield* makeWith$2((key) => head(key[0]), {
114384
+ capacity: Infinity,
114385
+ timeToLive: (exit) => match(isSuccess(exit) && isSome(exit.value), {
114386
+ onFalse: () => seconds(5),
114387
+ onTrue: () => infinity
114388
+ })
114389
+ });
114390
+ function probe(port, identity) {
114391
+ if (identity === "") return head(port);
114392
+ return get$7(probes, [port, identity]);
114393
+ }
114279
114394
  const units = fnUntraced(function* (system) {
114280
114395
  const scope = match(system, {
114281
114396
  onFalse: constant("user"),
@@ -114386,31 +114501,31 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114386
114501
  collect("User services", units(false)),
114387
114502
  collect("System services", units(true)),
114388
114503
  collect("Docker", docker),
114389
- collect("Listening ports", flatMap$3(command("ss", ["-H", "-lntup"]), (text) => portItems(getSomes(pipe(trim(text), split$1("\n"), map$10(socketLine))), worker, http, {
114504
+ collect("Listening ports", flatMap$3(command("ss", ["-H", "-lntup"]), (text) => portItems(getSomes(pipe(trim(text), split$1("\n"), map$10(socketLine))), worker, probe, {
114390
114505
  cwd: (processId) => option$1(fs.readLink(`/proc/${processId}/cwd`)),
114506
+ start: (processId) => map$7(option$1(fs.readFileString(`/proc/${processId}/stat`)), flatMap$8((stat) => flatMap$8(lastIndexOf(")")(stat), (at) => pipe(slice(at + 2)(stat), split$1(/\s+/u), get$12(19))))),
114391
114507
  unit: (processId) => map$7(option$1(fs.readFileString(`/proc/${processId}/cgroup`)), (cgroup) => socketUnit(getOrElse$1(cgroup, constant(""))))
114392
114508
  })))
114393
114509
  ]
114394
114510
  });
114511
+ const bundleNames = yield* make$71({
114512
+ capacity: Infinity,
114513
+ lookup: fnUntraced(function* (bundle) {
114514
+ return yield* pipe(command("/usr/bin/plutil", [
114515
+ "-convert",
114516
+ "json",
114517
+ "-o",
114518
+ "-",
114519
+ `${bundle}/Contents/Info.plist`
114520
+ ]), flatMap$3(decodeEffect(fromJsonString(Struct$2({
114521
+ CFBundleDisplayName: optionalKey(Unknown),
114522
+ CFBundleName: optionalKey(Unknown)
114523
+ })))), map$7((fields) => pipe([fields.CFBundleDisplayName, fields.CFBundleName], filter$5(isString$1), map$10(trim), findFirst(isNonEmpty$1))), option$1, map$7(flatten$6));
114524
+ })
114525
+ });
114395
114526
  const darwin = gen(function* () {
114396
114527
  const namedAgents = gen(function* () {
114397
- const agents = launchAgents(yield* command("launchctl", ["list"]));
114398
- const bundleNames = yield* make$71({
114399
- capacity: agents.length + 1,
114400
- lookup: fnUntraced(function* (bundle) {
114401
- return yield* pipe(command("/usr/bin/plutil", [
114402
- "-convert",
114403
- "json",
114404
- "-o",
114405
- "-",
114406
- `${bundle}/Contents/Info.plist`
114407
- ]), flatMap$3(decodeEffect(fromJsonString(Struct$2({
114408
- CFBundleDisplayName: optionalKey(Unknown),
114409
- CFBundleName: optionalKey(Unknown)
114410
- })))), map$7((fields) => pipe([fields.CFBundleDisplayName, fields.CFBundleName], filter$5(isString$1), map$10(trim), findFirst(isNonEmpty$1))), option$1, map$7(flatten$6));
114411
- })
114412
- });
114413
- return getSomes(yield* forEach$1(agents, fnUntraced(function* (agent) {
114528
+ return getSomes(yield* forEach$1(launchAgents(yield* command("launchctl", ["list"])), fnUntraced(function* (agent) {
114414
114529
  if (startsWith("deslop-")(agent.label)) return some$1(agent);
114415
114530
  const program = flatMap$8(yield* option$1(command("launchctl", ["print", `gui/${userInfo().uid}/${agent.label}`])), launchProgram);
114416
114531
  if (exists(program, systemProgram)) return none();
@@ -114465,6 +114580,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114465
114580
  return filter$5(launchdProcesses(text, agents), (record) => record.process.pid === selfProcess || !pipe(agents, get$9(selfProcess), contains$2(record.unit)));
114466
114581
  });
114467
114582
  const owned = getOrElse(records, empty$15);
114583
+ const starts = pipe(launchd.table, map$12(launchdStarts), getOrElse(empty$11));
114468
114584
  return {
114469
114585
  processes: map$7(fromResult(records), (found) => ({
114470
114586
  records: found,
@@ -114507,7 +114623,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114507
114623
  "-iUDP",
114508
114624
  "-F",
114509
114625
  "pctPnT"
114510
- ]), (text) => portItems(lsofSockets(text), worker, http, {
114626
+ ]), (text) => portItems(lsofSockets(text), worker, probe, {
114511
114627
  cwd: fnUntraced(function* (processId) {
114512
114628
  return pipe(yield* option$1(command("lsof", [
114513
114629
  "-nP",
@@ -114519,6 +114635,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114519
114635
  "-Fn"
114520
114636
  ])), getOrElse$1(constant("")), split$1("\n"), findFirst(startsWith("n")), map$13(slice(1)));
114521
114637
  }),
114638
+ start: (processId) => succeed$5(get$9(starts, processId)),
114522
114639
  unit: (processId) => succeed$5(pipe(owned, findFirst((record) => record.process.pid === processId), map$13((record) => record.unit)))
114523
114640
  })))
114524
114641
  ]
@@ -114633,9 +114750,10 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114633
114750
  };
114634
114751
  })), "Inventory.snapshot", { attributes: { worker } });
114635
114752
  const snapshot = yield* make$51(yield* collectSnapshot);
114636
- const refresh = pipe(snapshot, updateEffect(() => collectSnapshot), withSpan("Inventory.refresh"));
114637
- yield* pipe(refresh, schedule(spaced(seconds(5))), forkScoped);
114753
+ const [ensureFresh, invalidate] = yield* cachedInvalidateWithTTL(pipe(snapshot, updateEffect(() => collectSnapshot), withSpan("Inventory.refresh")), seconds(5));
114754
+ const refresh = andThen(invalidate, ensureFresh);
114638
114755
  return {
114756
+ ensureFresh,
114639
114757
  refresh,
114640
114758
  run: fn("Inventory.run")(function* (input) {
114641
114759
  yield* onExit$1(start(input), () => refresh);
@@ -114960,6 +115078,10 @@ function sampled(read) {
114960
115078
  try: read
114961
115079
  });
114962
115080
  }
115081
+ function sameBucket(row, time) {
115082
+ const step = toMillis(row.step);
115083
+ return Math.floor(toEpochMillis(row.since) / step) === Math.floor(toEpochMillis(time) / step);
115084
+ }
114963
115085
  var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service/Metrics", { make: gen(function* () {
114964
115086
  const fs = yield* FileSystem;
114965
115087
  const sql = yield* SqlClient;
@@ -115121,6 +115243,8 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
115121
115243
  }), loadavg(), old))
115122
115244
  };
115123
115245
  });
115246
+ const pending = yield* make$56(yield* asDeployError$1(listBuckets(yield* now)));
115247
+ const writes = yield* make$82(1);
115124
115248
  const collect = pipe(gen(function* () {
115125
115249
  const time = yield* now;
115126
115250
  const old = yield* get$2(previous);
@@ -115130,18 +115254,32 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
115130
115254
  onTrue: () => darwin(time, disks, old)
115131
115255
  });
115132
115256
  yield* set(previous, some$1(measured.current));
115133
- yield* pipe(listBuckets(time), flatMap$3((stored) => saveSamples(rollup(measured.value.point, stored))), sql.withTransaction, asDeployError$1);
115257
+ yield* writes.withPermits(1)(update(pending, (rows) => {
115258
+ const [current, completed] = partition(rows, fromPredicate((row) => sameBucket(row, time)));
115259
+ return [...completed, ...map$10(rollup(measured.value.point, current), (row) => evolve(row, { apps: (readings) => pipe(readings, filter$7(isReadonlyArrayNonEmpty), map$13(sort(mapInput(String$10, (app) => app.id)))) }))];
115260
+ }));
115134
115261
  yield* set(latest, {
115135
115262
  disks: measured.value.disks,
115136
115263
  load: measured.value.load
115137
115264
  });
115138
115265
  yield* set(failure, none());
115139
- }), withSpan("Metrics.collect", { attributes: { worker } }), tapError$3((cause) => logWarning("Metrics could not be sampled", cause)), catch_$2((cause) => set(failure, some$1(cause.message))));
115266
+ }), tapError$3((cause) => logWarning("Metrics could not be sampled", cause)), catch_$2((cause) => set(failure, some$1(cause.message))));
115267
+ const flush = pipe(gen(function* () {
115268
+ const rows = yield* get$2(pending);
115269
+ if (isReadonlyArrayNonEmpty(rows)) yield* pipe(saveSamples(rows), sql.withTransaction, asDeployError$1);
115270
+ const time = yield* now;
115271
+ yield* set(pending, filter$5(rows, (row) => sameBucket(row, time)));
115272
+ }), writes.withPermits(1), withSpan("Metrics.collect", { attributes: { worker } }), tapError$3((cause) => set(failure, some$1(cause.message))), ignore$1({
115273
+ log: "Error",
115274
+ message: "Resource history could not be saved"
115275
+ }));
115140
115276
  const prune = pipe(now, flatMap$3(deleteExpired), sql.withTransaction, asDeployError$1, withSpan("Metrics.prune", { attributes: { worker } }));
115141
115277
  yield* prune;
115142
115278
  yield* refreshStorage;
115143
115279
  yield* collect;
115280
+ yield* addFinalizer(() => flush);
115144
115281
  yield* pipe(collect, schedule(fixed(seconds(1))), forkScoped);
115282
+ yield* pipe(flush, schedule(fixed(seconds(10))), forkScoped);
115145
115283
  yield* pipe(refreshStorage, schedule(spaced(seconds(30))), forkScoped);
115146
115284
  yield* pipe(prune, ignore$1({
115147
115285
  log: "Error",
@@ -115154,9 +115292,13 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
115154
115292
  });
115155
115293
  const time = yield* now;
115156
115294
  const step = SERIES[yield* asDeployError$1(encodeEffect(HistoryQuery.fields.minutes)(query.minutes))];
115157
- const samples = yield* asDeployError$1(listSeries({
115158
- after: subtractDuration(chartWindow(query.minutes, time).start, step),
115159
- step
115295
+ const samples = yield* writes.withPermits(1)(gen(function* () {
115296
+ const stored = yield* asDeployError$1(listSeries({
115297
+ after: subtractDuration(chartWindow(query.minutes, time).start, step),
115298
+ step
115299
+ }));
115300
+ const buffered = filter$5(yield* get$2(pending), (row) => equals(row.step, step));
115301
+ return sort([...filter$5(stored, (row) => !some(buffered, (value) => Equivalence$3(value.since, row.since))), ...buffered], mapInput(Order$2, (row) => row.since));
115160
115302
  }));
115161
115303
  const now$2 = yield* get$2(latest);
115162
115304
  return {
@@ -115405,6 +115547,7 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
115405
115547
  });
115406
115548
  })),
115407
115549
  snapshot: withSpan(gen(function* () {
115550
+ yield* inventory.ensureFresh;
115408
115551
  const own = yield* local;
115409
115552
  const others = yield* forEach$1(workers, (worker) => pipe(remote(worker, (client) => client("inventory.snapshot", void 0)), timeout(seconds(2)), map$7((snapshot) => ({
115410
115553
  ...snapshot,
@@ -115472,7 +115615,7 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
115472
115615
  yield* onExit$1(exposures.hide(input.name), () => localInventory.refresh);
115473
115616
  }, onExit$1(() => invalidate(["deployInventory"]))),
115474
115617
  "inventory.run": fleet.run,
115475
- "inventory.snapshot": () => fleet.local,
115618
+ "inventory.snapshot": () => andThen(localInventory.ensureFresh, fleet.local),
115476
115619
  "inventory.start": (input) => onExit$1(localInventory.run(input), () => invalidate(["deployInventory"])),
115477
115620
  "inventory.watch": () => inventory,
115478
115621
  "metrics.history": fleet.history,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/deploy",
3
- "version": "0.1.1354",
3
+ "version": "0.1.1356",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/MP281X/deslop.git",
@@ -40,5 +40,5 @@
40
40
  "engines": {
41
41
  "node": ">=26"
42
42
  },
43
- "fingerprint": "f3757eec59c5a10dc96b3b1650f9409bfb7a26ba063b700c3b365ec5a987216a"
43
+ "fingerprint": "290edf03452767d3fb5143e04a205c3f494c1b0a4e2499894ed1a4e9c264a911"
44
44
  }