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();
|
||||
if (inside !== "true") {
|
||||
gitError = "not a git work tree";
|
||||
return {
|
||||
ts,
|
||||
branch,
|
||||
headShort,
|
||||
porcelainLines,
|
||||
hasUpstream,
|
||||
aheadCount,
|
||||
behindCount,
|
||||
gitError
|
||||
};
|
||||
return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
|
||||
}
|
||||
branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||
headShort = runGit(root, ["rev-parse", "--short", "HEAD"]);
|
||||
@ -86,16 +77,7 @@ async function compute() {
|
||||
} catch (e) {
|
||||
gitError = gitErrorMessage(e);
|
||||
}
|
||||
return {
|
||||
ts,
|
||||
branch,
|
||||
headShort,
|
||||
porcelainLines,
|
||||
hasUpstream,
|
||||
aheadCount,
|
||||
behindCount,
|
||||
gitError
|
||||
};
|
||||
return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
|
||||
}
|
||||
export {
|
||||
compute,
|
||||
|
||||
@ -47,16 +47,7 @@ export async function compute() {
|
||||
const inside = runGit(root, ["rev-parse", "--is-inside-work-tree"]).trim();
|
||||
if (inside !== "true") {
|
||||
gitError = "not a git work tree";
|
||||
return {
|
||||
ts,
|
||||
branch,
|
||||
headShort,
|
||||
porcelainLines,
|
||||
hasUpstream,
|
||||
aheadCount,
|
||||
behindCount,
|
||||
gitError,
|
||||
};
|
||||
return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
|
||||
}
|
||||
|
||||
branch = runGit(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||
@ -81,14 +72,5 @@ export async function compute() {
|
||||
gitError = gitErrorMessage(e);
|
||||
}
|
||||
|
||||
return {
|
||||
ts,
|
||||
branch,
|
||||
headShort,
|
||||
porcelainLines,
|
||||
hasUpstream,
|
||||
aheadCount,
|
||||
behindCount,
|
||||
gitError,
|
||||
};
|
||||
return { signal: { ts, branch, headShort, porcelainLines, hasUpstream, aheadCount, behindCount, gitError }, workflow: null };
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ async function compute() {
|
||||
httpLatencyMs,
|
||||
httpError
|
||||
};
|
||||
return row;
|
||||
return { signal: row, workflow: null };
|
||||
}
|
||||
export {
|
||||
compute,
|
||||
|
||||
@ -404,5 +404,5 @@ export async function compute() {
|
||||
httpError,
|
||||
};
|
||||
|
||||
return row;
|
||||
return { signal: row, workflow: null };
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ async function compute() {
|
||||
activeSessions,
|
||||
measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS
|
||||
};
|
||||
return row;
|
||||
return { signal: row, workflow: null };
|
||||
}
|
||||
export {
|
||||
compute,
|
||||
|
||||
@ -113,5 +113,5 @@ export async function compute() {
|
||||
measurementWindowSeconds: MEASUREMENT_WINDOW_SECONDS,
|
||||
};
|
||||
|
||||
return row;
|
||||
return { signal: row, workflow: null };
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ async function compute() {
|
||||
}
|
||||
const ts = Date.now();
|
||||
const uptimeSec = Math.round(uptime());
|
||||
return {
|
||||
const data = {
|
||||
ts,
|
||||
cpuLoad1m: load1,
|
||||
cpuLoad5m: load5,
|
||||
@ -99,6 +99,7 @@ async function compute() {
|
||||
tcpAlloc: tcp.tcpAlloc,
|
||||
tcpMemPages: tcp.tcpMemPages
|
||||
};
|
||||
return { signal: data, workflow: null };
|
||||
}
|
||||
export {
|
||||
compute,
|
||||
|
||||
@ -72,7 +72,7 @@ export async function compute() {
|
||||
const ts = Date.now();
|
||||
const uptimeSec = Math.round(uptime());
|
||||
|
||||
return {
|
||||
const data = {
|
||||
ts, cpuLoad1m: load1, cpuLoad5m: load5, cpuLoad15m: load15,
|
||||
memTotalMB, memUsedMB, memUsedPct,
|
||||
diskTotalGB, diskUsedGB, diskUsedPct,
|
||||
@ -84,4 +84,5 @@ export async function compute() {
|
||||
tcpAlloc: tcp.tcpAlloc,
|
||||
tcpMemPages: tcp.tcpMemPages,
|
||||
};
|
||||
return { signal: data, workflow: null };
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ async function compute() {
|
||||
rssMB,
|
||||
externalMB
|
||||
};
|
||||
return row;
|
||||
return { signal: row, workflow: null };
|
||||
}
|
||||
export {
|
||||
compute,
|
||||
|
||||
@ -22,5 +22,5 @@ export async function compute() {
|
||||
externalMB,
|
||||
};
|
||||
|
||||
return row;
|
||||
return { signal: row, workflow: null };
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user