




























@@ -47,6 +47,14 @@ import {
4747validateNodePairVerifyParams,
4848validateNodeRenameParams,
4949} from "../protocol/index.js";
50+import {
51+NODE_WAKE_RECONNECT_POLL_MS,
52+NODE_WAKE_RECONNECT_RETRY_WAIT_MS,
53+NODE_WAKE_RECONNECT_WAIT_MS,
54+nodeWakeById,
55+nodeWakeNudgeById,
56+type NodeWakeAttempt,
57+} from "./nodes-wake-state.js";
5058import { handleNodeInvokeResult } from "./nodes.handlers.invoke-result.js";
5159import {
5260respondInvalidParams,
@@ -56,31 +64,18 @@ import {
5664} from "./nodes.helpers.js";
5765import type { GatewayRequestHandlers } from "./types.js";
586659-export const NODE_WAKE_RECONNECT_WAIT_MS = 3_000;
60-export const NODE_WAKE_RECONNECT_RETRY_WAIT_MS = 12_000;
61-export const NODE_WAKE_RECONNECT_POLL_MS = 150;
67+export {
68+clearNodeWakeState,
69+NODE_WAKE_RECONNECT_POLL_MS,
70+NODE_WAKE_RECONNECT_RETRY_WAIT_MS,
71+NODE_WAKE_RECONNECT_WAIT_MS,
72+} from "./nodes-wake-state.js";
73+6274const NODE_WAKE_THROTTLE_MS = 15_000;
6375const NODE_WAKE_NUDGE_THROTTLE_MS = 10 * 60_000;
6476const NODE_PENDING_ACTION_TTL_MS = 10 * 60_000;
6577const NODE_PENDING_ACTION_MAX_PER_NODE = 64;
667867-type NodeWakeState = {
68-lastWakeAtMs: number;
69-inFlight?: Promise<NodeWakeAttempt>;
70-};
71-72-const nodeWakeById = new Map<string, NodeWakeState>();
73-const nodeWakeNudgeById = new Map<string, number>();
74-75-type NodeWakeAttempt = {
76-available: boolean;
77-throttled: boolean;
78-path: "throttled" | "no-registration" | "no-auth" | "sent" | "send-error";
79-durationMs: number;
80-apnsStatus?: number;
81-apnsReason?: string;
82-};
83-8479type NodeWakeNudgeAttempt = {
8580sent: boolean;
8681throttled: boolean;
@@ -518,15 +513,6 @@ export async function waitForNodeReconnect(params: {
518513return Boolean(params.context.nodeRegistry.get(params.nodeId));
519514}
520515521-/**
522- * Remove cached wake/nudge state for a node that has disconnected.
523- * Called from the WS close handler to prevent unbounded growth.
524- */
525-export function clearNodeWakeState(nodeId: string): void {
526-nodeWakeById.delete(nodeId);
527-nodeWakeNudgeById.delete(nodeId);
528-}
529-530516export const nodeHandlers: GatewayRequestHandlers = {
531517"node.pair.request": async ({ params, respond, context }) => {
532518if (!validateNodePairRequestParams(params)) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。