feat: update senses to return ComputeResult<T>
Wrap compute return values in { signal, workflow: null }
to match new SenseComputeFn contract.
— 小橘 🍊(NEKO Team)
This commit is contained in:
parent
1d9e574c94
commit
8774d71d57
@ -55,16 +55,7 @@ async function compute() {
|
|||||||
const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim();
|
const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim();
|
||||||
if (inside !== "true") {
|
if (inside !== "true") {
|
||||||
gitError = "not a git work tree";
|
gitError = "not a git work tree";
|
||||||
return {
|
return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
|
||||||
ts,
|
|
||||||
branch,
|
|
||||||
headShort,
|
|
||||||
porcelainLines,
|
|
||||||
hasUpstream,
|
|
||||||
aheadCount,
|
|
||||||
behindCount,
|
|
||||||
gitError
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||||
headShort = runGit(root, ["rev-parse", "--short", "HEAD"]);
|
headShort = runGit(root, ["rev-parse", "--short", "HEAD"]);
|
||||||
@ -86,16 +77,7 @@ async function compute() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
gitError = gitErrorMessage(e);
|
gitError = gitErrorMessage(e);
|
||||||
}
|
}
|
||||||
return {
|
return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
|
||||||
ts,
|
|
||||||
branch,
|
|
||||||
headShort,
|
|
||||||
porcelainLines,
|
|
||||||
hasUpstream,
|
|
||||||
aheadCount,
|
|
||||||
behindCount,
|
|
||||||
gitError
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
export {
|
export {
|
||||||
compute,
|
compute,
|
||||||
|
|||||||
@ -47,16 +47,7 @@ export async function compute() {
|
|||||||
const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim();
|
const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim();
|
||||||
if (inside !== "true") {
|
if (inside !== "true") {
|
||||||
gitError = "not a git work tree";
|
gitError = "not a git work tree";
|
||||||
return {
|
return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
|
||||||
ts,
|
|
||||||
branch,
|
|
||||||
headShort,
|
|
||||||
porcelainLines,
|
|
||||||
hasUpstream,
|
|
||||||
aheadCount,
|
|
||||||
behindCount,
|
|
||||||
gitError,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||||
@ -81,14 +72,5 @@ export async function compute() {
|
|||||||
gitError = gitErrorMessage(e);
|
gitError = gitErrorMessage(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
|
||||||
ts,
|
|
||||||
branch,
|
|
||||||
headShort,
|
|
||||||
porcelainLines,
|
|
||||||
hasUpstream,
|
|
||||||
aheadCount,
|
|
||||||
behindCount,
|
|
||||||
gitError,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -353,7 +353,7 @@ async function compute() {
|
|||||||
httpLatencyMs,
|
httpLatencyMs,
|
||||||
httpError
|
httpError
|
||||||
};
|
};
|
||||||
return row;
|
return { signal: row, workflow: null };
|
||||||
}
|
}
|
||||||
export {
|
export {
|
||||||
compute,
|
compute,
|
||||||
|
|||||||
@ -404,5 +404,5 @@ export async function compute() {
|
|||||||
httpError,
|
httpError,
|
||||||
};
|
};
|
||||||
|
|
||||||
return row;
|
return { signal: row, workflow: null };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,7 @@ async function compute() {
|
|||||||
activeSessions,
|
activeSessions,
|
||||||
measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS
|
measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS
|
||||||
};
|
};
|
||||||
return row;
|
return { signal: row, workflow: null };
|
||||||
}
|
}
|
||||||
export {
|
export {
|
||||||
compute,
|
compute,
|
||||||
|
|||||||
@ -113,5 +113,5 @@ export async function compute() {
|
|||||||
measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS,
|
measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS,
|
||||||
};
|
};
|
||||||
|
|
||||||
return row;
|
return { signal: row, workflow: null };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@ async function compute() {
|
|||||||
}
|
}
|
||||||
const ts = Date.now();
|
const ts = Date.now();
|
||||||
const uptimeSec = Math.round(uptime());
|
const uptimeSec = Math.round(uptime());
|
||||||
return {
|
const data = {
|
||||||
ts,
|
ts,
|
||||||
cpuLoad1m: load1,
|
cpuLoad1m: load1,
|
||||||
cpuLoad5m: load5,
|
cpuLoad5m: load5,
|
||||||
@ -99,6 +99,7 @@ async function compute() {
|
|||||||
tcpAlloc: tcp.tcpAlloc,
|
tcpAlloc: tcp.tcpAlloc,
|
||||||
tcpMemPages: tcp.tcpMemPages
|
tcpMemPages: tcp.tcpMemPages
|
||||||
};
|
};
|
||||||
|
return { signal: data, workflow: null };
|
||||||
}
|
}
|
||||||
export {
|
export {
|
||||||
compute,
|
compute,
|
||||||
|
|||||||
@ -72,7 +72,7 @@ export async function compute() {
|
|||||||
const ts = Date.now();
|
const ts = Date.now();
|
||||||
const uptimeSec = Math.round(uptime());
|
const uptimeSec = Math.round(uptime());
|
||||||
|
|
||||||
return {
|
const data = {
|
||||||
ts, cpuLoad1m: load1, cpuLoad5m: load5, cpuLoad15m: load15,
|
ts, cpuLoad1m: load1, cpuLoad5m: load5, cpuLoad15m: load15,
|
||||||
memTotalMB, memUsedMB, memUsedPct,
|
memTotalMB, memUsedMB, memUsedPct,
|
||||||
diskTotalGB, diskUsedGB, diskUsedPct,
|
diskTotalGB, diskUsedGB, diskUsedPct,
|
||||||
@ -84,4 +84,5 @@ export async function compute() {
|
|||||||
tcpAlloc: tcp.tcpAlloc,
|
tcpAlloc: tcp.tcpAlloc,
|
||||||
tcpMemPages: tcp.tcpMemPages,
|
tcpMemPages: tcp.tcpMemPages,
|
||||||
};
|
};
|
||||||
|
return { signal: data, workflow: null };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ async function compute() {
|
|||||||
rssMB,
|
rssMB,
|
||||||
externalMB
|
externalMB
|
||||||
};
|
};
|
||||||
return row;
|
return { signal: row, workflow: null };
|
||||||
}
|
}
|
||||||
export {
|
export {
|
||||||
compute,
|
compute,
|
||||||
|
|||||||
@ -22,5 +22,5 @@ export async function compute() {
|
|||||||
externalMB,
|
externalMB,
|
||||||
};
|
};
|
||||||
|
|
||||||
return row;
|
return { signal: row, workflow: null };
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user