openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
59 lines (58 loc) • 1.85 kB
JavaScript
import { t as formatErrorMessage } from "./errors-BKzCeTYb.mjs";
import { n as executeExistingOpenClawStateRead } from "./openclaw-state-db-readonly-B6YHb1oF.mjs";
import { r as resolveChannelIngressStateEnv, t as channelIngressHealthCache } from "./ingress-queue-health-cache-Du0xxr3k.mjs";
//#region src/channels/message/ingress-queue-health.ts
/** Redacted health diagnostics for durable channel ingress queues. */
async function countFailedChannelIngressQueueEntries(e) {
const t = await executeExistingOpenClawStateRead({ env: resolveChannelIngressStateEnv(e) }, { type: "channelIngress.failedHealth" });
if (!t) return [];
return t.result;
}
async function countChannelIngressQueueHealth(e, t) {
const n = t ? channelIngressHealthCache(t) : void 0;
const r = Date.now();
const i = n?.failed;
const a = n?.pressure && r >= n.pressure.readAtMs && r < (n.pressure.nextClaimExpiryAtMs ?? Infinity) ? n.pressure.pressure : void 0;
if (i && a) return {
failed: i,
pressure: a
};
try {
const t = await executeExistingOpenClawStateRead({ env: resolveChannelIngressStateEnv(e) }, {
type: "channelIngress.health",
input: {
now: r,
failed: !i,
pressure: !a
}
});
if (!t) return {
failed: i ?? [],
pressure: a ?? []
};
if (n) {
if (t.result.failed) n.failed = t.result.failed;
if (t.result.pressure) n.pressure = {
...t.result.pressure,
readAtMs: r
};
}
return {
failed: t.result.failed ?? i ?? [],
pressure: t.result.pressure?.pressure ?? a ?? [],
errors: t.result.errors
};
} catch (e) {
const t = formatErrorMessage(e);
return {
failed: i ?? [],
pressure: a ?? [],
errors: {
...!i ? { failed: t } : {},
...!a ? { pressure: t } : {}
}
};
}
}
//#endregion
export { countFailedChannelIngressQueueEntries as n, countChannelIngressQueueHealth as t };