Files
justme fb3a9c260f fleet: send log counters in heartbeats and pull the text on demand
Heartbeats carry per-level counts, the most frequent log types (a stable hash of the message) and the newest id, no text. The node keeps its last 2048 lines; moshiro.logs.fetch lets the backend pull them. The log page pulls when it is open, and the backend pulls warnings and errors once a minute after a node reports an error.
2026-10-22 05:28:29 +08:00

47 lines
2.6 KiB
C#

using Fleet.Rpc;
namespace MoShiro.Protocol;
/// <summary>
/// 所有方法和二进制通道的方向声明,单一真源(框架的 <c>fleet.*</c> 见 <see cref="FleetMethodTable"/>)。
/// 新增一个方法:在 <see cref="MoShiroMethods"/> 里加名字和参数,在这里加一行声明,再在对应一侧注册处理函数;
/// 声明了但没人处理、或者处理了但没声明,都会被测试和启动时的检查发现。
/// 同一个方法名只有一个发起方;节点面是服务端和节点,对等面是拨号方和监听方。所有节点是同一种角色:
/// 能做什么由节点的配置(是否监听)和 Backend 下发的期望状态决定,声明表不区分节点类型。
/// </summary>
public static class MoShiroMethodTable
{
public static readonly MethodTable Table = MethodTable.Combine(
FleetMethodTable.Table,
new MethodTable(
[
// 节点面:Backend → 节点
MethodSpec.Request(MoShiroMethods.TestRun, RpcSide.Server),
MethodSpec.Request(MoShiroMethods.TestCancel, RpcSide.Server),
MethodSpec.Request(MoShiroMethods.DialerDisconnect, RpcSide.Server),
MethodSpec.Request(MoShiroMethods.LogsFetch, RpcSide.Server),
MethodSpec.Notification(MoShiroMethods.LinkRetry, RpcSide.Server),
MethodSpec.Notification(MoShiroMethods.UpdateOffer, RpcSide.Server),
MethodSpec.Notification(MoShiroMethods.UpdateApply, RpcSide.Server),
MethodSpec.Notification(MoShiroMethods.Schedule, RpcSide.Server),
// 节点面:节点 → Backend
MethodSpec.Notification(MoShiroMethods.TestStatus, RpcSide.Node),
MethodSpec.Notification(MoShiroMethods.Event, RpcSide.Node),
MethodSpec.Notification(MoShiroMethods.Host, RpcSide.Node),
// 对等面:拨号方 → 监听方
MethodSpec.Request(MoShiroMethods.Clock, RpcSide.Dialer),
// 对等面:监听方 → 拨号方
MethodSpec.Request(MoShiroMethods.TestPhase, RpcSide.Listener),
MethodSpec.Request(MoShiroMethods.TestPhaseEnd, RpcSide.Listener),
MethodSpec.Notification(MoShiroMethods.TestAbort, RpcSide.Listener),
],
[
// 原始块:节点往 Backend 发;列块:拨号方经对等会话发给监听方
new ChannelSpec(MoShiroChannels.RawChunk, RpcSide.Node),
new ChannelSpec(MoShiroChannels.ColumnBlock, RpcSide.Dialer),
]));
}