Skip to content

Commit 4bae788

Browse files
committed
refactor(gateway): share runtime service helpers
1 parent 1db2c2a commit 4bae788

3 files changed

Lines changed: 26 additions & 31 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { OpenClawConfig } from "../config/types.openclaw.js";
2+
import type { HeartbeatRunner } from "../infra/heartbeat-runner.js";
3+
4+
export type GatewayRuntimeServiceLogger = {
5+
child: (name: string) => {
6+
info: (message: string) => void;
7+
warn: (message: string) => void;
8+
error: (message: string) => void;
9+
};
10+
error: (message: string) => void;
11+
};
12+
13+
export function createNoopHeartbeatRunner(): HeartbeatRunner {
14+
return {
15+
stop: () => {},
16+
updateConfig: (_cfg: OpenClawConfig) => {},
17+
};
18+
}

src/gateway/server-runtime-services.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,23 @@ import { startHeartbeatRunner, type HeartbeatRunner } from "../infra/heartbeat-r
44
import type { PluginMetadataRegistryView } from "../plugins/plugin-metadata-snapshot.types.js";
55
import { isGatewayModelPricingEnabled } from "./model-pricing-config.js";
66
import type { startGatewayMaintenanceTimers } from "./server-maintenance.js";
7+
import {
8+
createNoopHeartbeatRunner,
9+
type GatewayRuntimeServiceLogger,
10+
} from "./server-runtime-service-shared.js";
711
export {
812
startGatewayChannelHealthMonitor,
913
startGatewayRuntimeServices,
1014
type GatewayChannelManager,
1115
} from "./server-runtime-startup-services.js";
1216

13-
type GatewayRuntimeServiceLogger = {
14-
child: (name: string) => {
15-
info: (message: string) => void;
16-
warn: (message: string) => void;
17-
error: (message: string) => void;
18-
};
19-
error: (message: string) => void;
20-
};
2117
type GatewayPostReadyLogger = {
2218
warn: (message: string) => void;
2319
};
2420
export type GatewayMaintenanceHandles = NonNullable<
2521
Awaited<ReturnType<typeof startGatewayMaintenanceTimers>>
2622
>;
2723

28-
function createNoopHeartbeatRunner(): HeartbeatRunner {
29-
return {
30-
stop: () => {},
31-
updateConfig: (_cfg: OpenClawConfig) => {},
32-
};
33-
}
34-
3524
/** Starts cron without making gateway startup wait for cron initialization. */
3625
export function startGatewayCronWithLogging(params: {
3726
cron: { start: () => Promise<void> };

src/gateway/server-runtime-startup-services.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
import type { OpenClawConfig } from "../config/types.openclaw.js";
22
import type { ChannelHealthMonitor } from "./channel-health-monitor.js";
33
import { startChannelHealthMonitor } from "./channel-health-monitor.js";
4-
5-
type GatewayRuntimeServiceLogger = {
6-
child: (name: string) => {
7-
info: (message: string) => void;
8-
warn: (message: string) => void;
9-
error: (message: string) => void;
10-
};
11-
error: (message: string) => void;
12-
};
4+
import {
5+
createNoopHeartbeatRunner,
6+
type GatewayRuntimeServiceLogger,
7+
} from "./server-runtime-service-shared.js";
138

149
export type GatewayChannelManager = Parameters<
1510
typeof startChannelHealthMonitor
1611
>[0]["channelManager"];
1712

18-
function createNoopHeartbeatRunner() {
19-
return {
20-
stop: () => {},
21-
updateConfig: (_cfg: OpenClawConfig) => {},
22-
};
23-
}
24-
2513
export function startGatewayChannelHealthMonitor(params: {
2614
cfg: OpenClawConfig;
2715
channelManager: GatewayChannelManager;

0 commit comments

Comments
 (0)