mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 11:02:26 +00:00
chore(deadcode): remove unused main-lane queue wrapper
This commit is contained in:
@@ -25,7 +25,6 @@ type CommandQueueModule = typeof import("./command-queue.js");
|
||||
let clearCommandLane: CommandQueueModule["clearCommandLane"];
|
||||
let CommandLaneClearedError: CommandQueueModule["CommandLaneClearedError"];
|
||||
let CommandLaneTaskTimeoutError: CommandQueueModule["CommandLaneTaskTimeoutError"];
|
||||
let enqueueCommand: CommandQueueModule["enqueueCommand"];
|
||||
let enqueueCommandInLane: CommandQueueModule["enqueueCommandInLane"];
|
||||
let GatewayDrainingError: CommandQueueModule["GatewayDrainingError"];
|
||||
let getActiveTaskCount: CommandQueueModule["getActiveTaskCount"];
|
||||
@@ -69,7 +68,7 @@ function enqueueBlockedMainTask<T = void>(
|
||||
release: () => void;
|
||||
} {
|
||||
const deferred = createDeferred();
|
||||
const task = enqueueCommand(async () => {
|
||||
const task = enqueueCommandInLane(CommandLane.Main, async () => {
|
||||
await deferred.promise;
|
||||
return (await onRelease?.()) as T;
|
||||
});
|
||||
@@ -98,7 +97,6 @@ describe("command queue", () => {
|
||||
clearCommandLane,
|
||||
CommandLaneClearedError,
|
||||
CommandLaneTaskTimeoutError,
|
||||
enqueueCommand,
|
||||
enqueueCommandInLane,
|
||||
GatewayDrainingError,
|
||||
getActiveTaskCount,
|
||||
@@ -152,9 +150,9 @@ describe("command queue", () => {
|
||||
};
|
||||
|
||||
const results = await Promise.all([
|
||||
enqueueCommand(makeTask(1)),
|
||||
enqueueCommand(makeTask(2)),
|
||||
enqueueCommand(makeTask(3)),
|
||||
enqueueCommandInLane(CommandLane.Main, makeTask(1)),
|
||||
enqueueCommandInLane(CommandLane.Main, makeTask(2)),
|
||||
enqueueCommandInLane(CommandLane.Main, makeTask(3)),
|
||||
]);
|
||||
|
||||
expect(results).toEqual([1, 2, 3]);
|
||||
@@ -271,7 +269,7 @@ describe("command queue", () => {
|
||||
});
|
||||
|
||||
it("logs enqueue depth after push", async () => {
|
||||
const task = enqueueCommand(async () => {});
|
||||
const task = enqueueCommandInLane(CommandLane.Main, async () => {});
|
||||
|
||||
expect(diagnosticMocks.logLaneEnqueue).toHaveBeenCalledTimes(1);
|
||||
expect(mockCallArg(diagnosticMocks.logLaneEnqueue, "logLaneEnqueue", 1)).toBe(1);
|
||||
@@ -286,11 +284,11 @@ describe("command queue", () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const blocker = createDeferred();
|
||||
const first = enqueueCommand(async () => {
|
||||
const first = enqueueCommandInLane(CommandLane.Main, async () => {
|
||||
await blocker.promise;
|
||||
});
|
||||
|
||||
const second = enqueueCommand(async () => {}, {
|
||||
const second = enqueueCommandInLane(CommandLane.Main, async () => {}, {
|
||||
warnAfterMs: 5,
|
||||
onWait: (ms, ahead) => {
|
||||
waited = ms;
|
||||
@@ -784,7 +782,7 @@ describe("command queue", () => {
|
||||
const { task: first, release } = enqueueBlockedMainTask(async () => "first");
|
||||
|
||||
// Second task is queued behind the first.
|
||||
const second = enqueueCommand(async () => "second");
|
||||
const second = enqueueCommandInLane(CommandLane.Main, async () => "second");
|
||||
|
||||
const removed = clearCommandLane();
|
||||
expect(removed).toBe(1); // only the queued (not active) entry
|
||||
@@ -822,9 +820,9 @@ describe("command queue", () => {
|
||||
|
||||
it("rejects new enqueues with GatewayDrainingError after markGatewayDraining", async () => {
|
||||
markGatewayDraining();
|
||||
await expect(enqueueCommand(async () => "blocked")).rejects.toBeInstanceOf(
|
||||
GatewayDrainingError,
|
||||
);
|
||||
await expect(
|
||||
enqueueCommandInLane(CommandLane.Main, async () => "blocked"),
|
||||
).rejects.toBeInstanceOf(GatewayDrainingError);
|
||||
});
|
||||
|
||||
it("does not affect already-active tasks after markGatewayDraining", async () => {
|
||||
@@ -837,7 +835,7 @@ describe("command queue", () => {
|
||||
it("resetAllLanes clears gateway draining flag and re-allows enqueue", async () => {
|
||||
markGatewayDraining();
|
||||
resetAllLanes();
|
||||
await expect(enqueueCommand(async () => "ok")).resolves.toBe("ok");
|
||||
await expect(enqueueCommandInLane(CommandLane.Main, async () => "ok")).resolves.toBe("ok");
|
||||
});
|
||||
|
||||
it("migrates legacy queue state missing activeTaskWaiters without crashing", async () => {
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
logLaneDequeue,
|
||||
logLaneEnqueue,
|
||||
} from "../logging/diagnostic-runtime.js";
|
||||
import { clampPositiveTimerTimeoutMs } from "../shared/number-coercion.js";
|
||||
import { resolveGlobalSingleton } from "../shared/global-singleton.js";
|
||||
import { clampPositiveTimerTimeoutMs } from "../shared/number-coercion.js";
|
||||
import type { CommandQueueEnqueueOptions } from "./command-queue.types.js";
|
||||
import { CommandLane } from "./lanes.js";
|
||||
/**
|
||||
@@ -507,13 +507,6 @@ export function enqueueCommandInLane<T>(
|
||||
});
|
||||
}
|
||||
|
||||
export function enqueueCommand<T>(
|
||||
task: () => Promise<T>,
|
||||
opts?: CommandQueueEnqueueOptions,
|
||||
): Promise<T> {
|
||||
return enqueueCommandInLane(CommandLane.Main, task, opts);
|
||||
}
|
||||
|
||||
export function getQueueSize(lane: string = CommandLane.Main) {
|
||||
const resolved = normalizeLane(lane);
|
||||
const state = getQueueState().lanes.get(resolved);
|
||||
|
||||
Reference in New Issue
Block a user